v1.0 with SW PWA enabled
This commit is contained in:
201
frontend/node_modules/@eslint/plugin-kit/LICENSE
generated
vendored
Normal file
201
frontend/node_modules/@eslint/plugin-kit/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
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.
|
||||
273
frontend/node_modules/@eslint/plugin-kit/README.md
generated
vendored
Normal file
273
frontend/node_modules/@eslint/plugin-kit/README.md
generated
vendored
Normal file
@ -0,0 +1,273 @@
|
||||
# ESLint Plugin Kit
|
||||
|
||||
## Description
|
||||
|
||||
A collection of utilities to help build ESLint plugins.
|
||||
|
||||
## Installation
|
||||
|
||||
For Node.js and compatible runtimes:
|
||||
|
||||
```shell
|
||||
npm install @eslint/plugin-kit
|
||||
# or
|
||||
yarn add @eslint/plugin-kit
|
||||
# or
|
||||
pnpm install @eslint/plugin-kit
|
||||
# or
|
||||
bun add @eslint/plugin-kit
|
||||
```
|
||||
|
||||
For Deno:
|
||||
|
||||
```shell
|
||||
deno add @eslint/plugin-kit
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This package exports the following utilities:
|
||||
|
||||
- [`ConfigCommentParser`](#configcommentparser) - used to parse ESLint configuration comments (i.e., `/* eslint-disable rule */`)
|
||||
- [`VisitNodeStep` and `CallMethodStep`](#visitnodestep-and-callmethodstep) - used to help implement `SourceCode#traverse()`
|
||||
- [`Directive`](#directive) - used to help implement `SourceCode#getDisableDirectives()`
|
||||
- [`TextSourceCodeBase`](#textsourcecodebase) - base class to help implement the `SourceCode` interface
|
||||
|
||||
### `ConfigCommentParser`
|
||||
|
||||
To use the `ConfigCommentParser` class, import it from the package and create a new instance, such as:
|
||||
|
||||
```js
|
||||
import { ConfigCommentParser } from "@eslint/plugin-kit";
|
||||
|
||||
// create a new instance
|
||||
const commentParser = new ConfigCommentParser();
|
||||
|
||||
// pass in a comment string without the comment delimiters
|
||||
const directive = commentParser.parseDirective(
|
||||
"eslint-disable prefer-const, semi -- I don't want to use these.",
|
||||
);
|
||||
|
||||
// will be undefined when a directive can't be parsed
|
||||
if (directive) {
|
||||
console.log(directive.label); // "eslint-disable"
|
||||
console.log(directive.value); // "prefer-const, semi"
|
||||
console.log(directive.justification); // "I don't want to use these."
|
||||
}
|
||||
```
|
||||
|
||||
There are different styles of directive values that you'll need to parse separately to get the correct format:
|
||||
|
||||
```js
|
||||
import { ConfigCommentParser } from "@eslint/plugin-kit";
|
||||
|
||||
// create a new instance
|
||||
const commentParser = new ConfigCommentParser();
|
||||
|
||||
// list format
|
||||
const list = commentParser.parseListConfig("prefer-const, semi");
|
||||
console.log(Object.entries(list)); // [["prefer-const", true], ["semi", true]]
|
||||
|
||||
// string format
|
||||
const strings = commentParser.parseStringConfig("foo:off, bar");
|
||||
console.log(Object.entries(strings)); // [["foo", "off"], ["bar", null]]
|
||||
|
||||
// JSON-like config format
|
||||
const jsonLike = commentParser.parseJSONLikeConfig(
|
||||
"semi:[error, never], prefer-const: warn",
|
||||
);
|
||||
console.log(Object.entries(jsonLike.config)); // [["semi", ["error", "never"]], ["prefer-const", "warn"]]
|
||||
```
|
||||
|
||||
### `VisitNodeStep` and `CallMethodStep`
|
||||
|
||||
The `VisitNodeStep` and `CallMethodStep` classes represent steps in the traversal of source code. They implement the correct interfaces to return from the `SourceCode#traverse()` method.
|
||||
|
||||
The `VisitNodeStep` class is the more common of the two, where you are describing a visit to a particular node during the traversal. The constructor accepts three arguments:
|
||||
|
||||
- `target` - the node being visited. This is used to determine the method to call inside of a rule. For instance, if the node's type is `Literal` then ESLint will call a method named `Literal()` on the rule (if present).
|
||||
- `phase` - either 1 for enter or 2 for exit.
|
||||
- `args` - an array of arguments to pass into the visitor method of a rule.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
import { VisitNodeStep } from "@eslint/plugin-kit";
|
||||
|
||||
class MySourceCode {
|
||||
traverse() {
|
||||
const steps = [];
|
||||
|
||||
for (const { node, parent, phase } of iterator(this.ast)) {
|
||||
steps.push(
|
||||
new VisitNodeStep({
|
||||
target: node,
|
||||
phase: phase === "enter" ? 1 : 2,
|
||||
args: [node, parent],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `CallMethodStep` class is less common and is used to tell ESLint to call a specific method on the rule. The constructor accepts two arguments:
|
||||
|
||||
- `target` - the name of the method to call, frequently beginning with `"on"` such as `"onCodePathStart"`.
|
||||
- `args` - an array of arguments to pass to the method.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
import { VisitNodeStep, CallMethodStep } from "@eslint/plugin-kit";
|
||||
|
||||
class MySourceCode {
|
||||
traverse() {
|
||||
const steps = [];
|
||||
|
||||
for (const { node, parent, phase } of iterator(this.ast)) {
|
||||
steps.push(
|
||||
new VisitNodeStep({
|
||||
target: node,
|
||||
phase: phase === "enter" ? 1 : 2,
|
||||
args: [node, parent],
|
||||
}),
|
||||
);
|
||||
|
||||
// call a method indicating how many times we've been through the loop
|
||||
steps.push(
|
||||
new CallMethodStep({
|
||||
target: "onIteration",
|
||||
args: [steps.length]
|
||||
});
|
||||
)
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `Directive`
|
||||
|
||||
The `Directive` class represents a disable directive in the source code and implements the `Directive` interface from `@eslint/core`. You can tell ESLint about disable directives using the `SourceCode#getDisableDirectives()` method, where part of the return value is an array of `Directive` objects. Here's an example:
|
||||
|
||||
```js
|
||||
import { Directive, ConfigCommentParser } from "@eslint/plugin-kit";
|
||||
|
||||
class MySourceCode {
|
||||
getDisableDirectives() {
|
||||
const directives = [];
|
||||
const problems = [];
|
||||
const commentParser = new ConfigCommentParser();
|
||||
|
||||
// read in the inline config nodes to check each one
|
||||
this.getInlineConfigNodes().forEach(comment => {
|
||||
// Step 1: Parse the directive
|
||||
const { label, value, justification } =
|
||||
commentParser.parseDirective(comment.value);
|
||||
|
||||
// Step 2: Extract the directive value and create the `Directive` object
|
||||
switch (label) {
|
||||
case "eslint-disable":
|
||||
case "eslint-enable":
|
||||
case "eslint-disable-next-line":
|
||||
case "eslint-disable-line": {
|
||||
const directiveType = label.slice("eslint-".length);
|
||||
|
||||
directives.push(
|
||||
new Directive({
|
||||
type: directiveType,
|
||||
node: comment,
|
||||
value,
|
||||
justification,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// ignore any comments that don't begin with known labels
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
directives,
|
||||
problems,
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `TextSourceCodeBase`
|
||||
|
||||
The `TextSourceCodeBase` class is intended to be a base class that has several of the common members found in `SourceCode` objects already implemented. Those members are:
|
||||
|
||||
- `lines` - an array of text lines that is created automatically when the constructor is called.
|
||||
- `getLoc(nodeOrToken)` - gets the location of a node or token. Works for nodes that have the ESLint-style `loc` property and nodes that have the Unist-style [`position` property](https://github.com/syntax-tree/unist?tab=readme-ov-file#position). If you're using an AST with a different location format, you'll still need to implement this method yourself.
|
||||
- `getLocFromIndex(index)` - Converts a source text index into a `{ line: number, column: number }` pair. (For this method to work, the root node should always cover the entire source code text, and the `getLoc()` method needs to be implemented correctly.)
|
||||
- `getIndexFromLoc(loc)` - Converts a `{ line: number, column: number }` pair into a source text index. (For this method to work, the root node should always cover the entire source code text, and the `getLoc()` method needs to be implemented correctly.)
|
||||
- `getRange(nodeOrToken)` - gets the range of a node or token within the source text. Works for nodes that have the ESLint-style `range` property and nodes that have the Unist-style [`position` property](https://github.com/syntax-tree/unist?tab=readme-ov-file#position). If you're using an AST with a different range format, you'll still need to implement this method yourself.
|
||||
- `getText(node, beforeCount, afterCount)` - gets the source text for the given node that has range information attached. Optionally, can return additional characters before and after the given node. As long as `getRange()` is properly implemented, this method will just work.
|
||||
- `getAncestors(node)` - returns the ancestry of the node. In order for this to work, you must implement the `getParent()` method yourself.
|
||||
|
||||
Here's an example:
|
||||
|
||||
```js
|
||||
import { TextSourceCodeBase } from "@eslint/plugin-kit";
|
||||
|
||||
export class MySourceCode extends TextSourceCodeBase {
|
||||
#parents = new Map();
|
||||
|
||||
constructor({ ast, text }) {
|
||||
super({ ast, text });
|
||||
}
|
||||
|
||||
getParent(node) {
|
||||
return this.#parents.get(node);
|
||||
}
|
||||
|
||||
traverse() {
|
||||
const steps = [];
|
||||
|
||||
for (const { node, parent, phase } of iterator(this.ast)) {
|
||||
//save the parent information
|
||||
this.#parent.set(node, parent);
|
||||
|
||||
steps.push(
|
||||
new VisitNodeStep({
|
||||
target: node,
|
||||
phase: phase === "enter" ? 1 : 2,
|
||||
args: [node, parent],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In general, it's safe to collect the parent information during the `traverse()` method as `getParent()` and `getAncestor()` will only be called from rules once the AST has been traversed at least once.
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<p><a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
|
||||
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
|
||||
<!--sponsorsend-->
|
||||
884
frontend/node_modules/@eslint/plugin-kit/dist/cjs/index.cjs
generated
vendored
Normal file
884
frontend/node_modules/@eslint/plugin-kit/dist/cjs/index.cjs
generated
vendored
Normal file
@ -0,0 +1,884 @@
|
||||
'use strict';
|
||||
|
||||
var levn = require('levn');
|
||||
|
||||
/**
|
||||
* @fileoverview Config Comment Parser
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @import * as $eslintcore from "@eslint/core"; */
|
||||
/** @typedef {$eslintcore.RuleConfig} RuleConfig */
|
||||
/** @typedef {$eslintcore.RulesConfig} RulesConfig */
|
||||
/** @import * as $typests from "./types.ts"; */
|
||||
/** @typedef {$typests.StringConfig} StringConfig */
|
||||
/** @typedef {$typests.BooleanConfig} BooleanConfig */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const directivesPattern = /^([a-z]+(?:-[a-z]+)*)(?:\s|$)/u;
|
||||
const validSeverities = new Set([0, 1, 2, "off", "warn", "error"]);
|
||||
|
||||
/**
|
||||
* Determines if the severity in the rule configuration is valid.
|
||||
* @param {RuleConfig} ruleConfig A rule's configuration.
|
||||
* @returns {boolean} `true` if the severity is valid, otherwise `false`.
|
||||
*/
|
||||
function isSeverityValid(ruleConfig) {
|
||||
const severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
|
||||
return validSeverities.has(severity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if all severities in the rules configuration are valid.
|
||||
* @param {RulesConfig} rulesConfig The rules configuration to check.
|
||||
* @returns {boolean} `true` if all severities are valid, otherwise `false`.
|
||||
*/
|
||||
function isEverySeverityValid(rulesConfig) {
|
||||
return Object.values(rulesConfig).every(isSeverityValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
class DirectiveComment {
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label = "";
|
||||
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value = "";
|
||||
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification = "";
|
||||
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label, value, justification) {
|
||||
this.label = label;
|
||||
this.value = value;
|
||||
this.justification = justification;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
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.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string) {
|
||||
const items = /** @type {StringConfig} */ ({});
|
||||
|
||||
// Collapse whitespace around `:` and `,` to make parsing easier
|
||||
const trimmedString = string
|
||||
.trim()
|
||||
.replace(/(?<!\s)\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;
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string) {
|
||||
// Parses a JSON-like comment by the same way as parsing CLI option.
|
||||
try {
|
||||
const items =
|
||||
/** @type {RulesConfig} */ (levn.parse("Object", string)) || {};
|
||||
|
||||
/*
|
||||
* When the configuration has any invalid severities, it should be completely
|
||||
* ignored. This is because the configuration is not valid and should not be
|
||||
* applied.
|
||||
*
|
||||
* For example, the following configuration is invalid:
|
||||
*
|
||||
* "no-alert: 2 no-console: 2"
|
||||
*
|
||||
* This results in a configuration of { "no-alert": "2 no-console: 2" }, which is
|
||||
* not valid. In this case, the configuration should be ignored.
|
||||
*/
|
||||
if (isEverySeverityValid(items)) {
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// levn parsing error: 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/])([-a-zA-Z0-9/]+):/gu, '"$1":')
|
||||
.replace(/([\]0-9])\s+(?=")/u, "$1,");
|
||||
|
||||
try {
|
||||
const items = JSON.parse(`{${normalizedString}}`);
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
} catch (ex) {
|
||||
const errorMessage = ex instanceof Error ? ex.message : String(ex);
|
||||
|
||||
return {
|
||||
ok: false,
|
||||
error: {
|
||||
message: `Failed to parse JSON from '${normalizedString}': ${errorMessage}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string) {
|
||||
const items = /** @type {BooleanConfig} */ ({});
|
||||
|
||||
string.split(",").forEach(name => {
|
||||
const trimmedName = name
|
||||
.trim()
|
||||
.replace(
|
||||
/^(?<quote>['"]?)(?<ruleId>.*)\k<quote>$/su,
|
||||
"$<ruleId>",
|
||||
);
|
||||
|
||||
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 {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string) {
|
||||
const { directivePart, justificationPart } =
|
||||
this.#extractDirectiveComment(string);
|
||||
const match = directivesPattern.exec(directivePart);
|
||||
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const directiveText = match[1];
|
||||
const directiveValue = directivePart.slice(
|
||||
match.index + directiveText.length,
|
||||
);
|
||||
|
||||
return new DirectiveComment(
|
||||
directiveText,
|
||||
directiveValue.trim(),
|
||||
justificationPart,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview A collection of helper classes for implementing `SourceCode`.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
/* eslint class-methods-use-this: off -- Required to complete interface. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {$eslintcore.VisitTraversalStep} VisitTraversalStep */
|
||||
/** @typedef {$eslintcore.CallTraversalStep} CallTraversalStep */
|
||||
/** @typedef {$eslintcore.TraversalStep} TraversalStep */
|
||||
/** @typedef {$eslintcore.SourceLocation} SourceLocation */
|
||||
/** @typedef {$eslintcore.SourceLocationWithOffset} SourceLocationWithOffset */
|
||||
/** @typedef {$eslintcore.SourceRange} SourceRange */
|
||||
/** @typedef {$eslintcore.Directive} IDirective */
|
||||
/** @typedef {$eslintcore.DirectiveType} DirectiveType */
|
||||
/** @typedef {$eslintcore.SourceCodeBaseTypeOptions} SourceCodeBaseTypeOptions */
|
||||
/**
|
||||
* @typedef {import("@eslint/core").TextSourceCode<Options>} TextSourceCode<Options>
|
||||
* @template {SourceCodeBaseTypeOptions} [Options=SourceCodeBaseTypeOptions]
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {loc:SourceLocation}} `true` if the node has ESTree-style loc information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleLoc(node) {
|
||||
return "loc" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocation}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleLoc(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {range:SourceRange}} `true` if the node has ESTree-style range information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleRange(node) {
|
||||
return "range" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocationWithOffset}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleRange(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs binary search to find the line number containing a given target index.
|
||||
* Returns the lower bound - the index of the first element greater than the target.
|
||||
* **Please note that the `lineStartIndices` should be sorted in ascending order**.
|
||||
* - Time Complexity: O(log n) - Significantly faster than linear search for large files.
|
||||
* @param {number[]} lineStartIndices Sorted array of line start indices.
|
||||
* @param {number} targetIndex The target index to find the line number for.
|
||||
* @returns {number} The line number for the target index.
|
||||
*/
|
||||
function findLineNumberBinarySearch(lineStartIndices, targetIndex) {
|
||||
let low = 0;
|
||||
let high = lineStartIndices.length - 1;
|
||||
|
||||
while (low < high) {
|
||||
const mid = ((low + high) / 2) | 0; // Use bitwise OR to floor the division.
|
||||
|
||||
if (targetIndex < lineStartIndices[mid]) {
|
||||
high = mid;
|
||||
} else {
|
||||
low = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
class VisitNodeStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "visit";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 1;
|
||||
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase;
|
||||
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }) {
|
||||
this.target = target;
|
||||
this.phase = phase;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
class CallMethodStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "call";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 2;
|
||||
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }) {
|
||||
this.target = target;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
class Directive {
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
type;
|
||||
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @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 {unknown} 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
class TextSourceCodeBase {
|
||||
/**
|
||||
* The lines of text in the source code.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
#lines = [];
|
||||
|
||||
/**
|
||||
* The indices of the start of each line in the source code.
|
||||
* @type {Array<number>}
|
||||
*/
|
||||
#lineStartIndices = [0];
|
||||
|
||||
/**
|
||||
* The pattern to match lineEndings in the source code.
|
||||
* @type {RegExp}
|
||||
*/
|
||||
#lineEndingPattern;
|
||||
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast;
|
||||
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code. Defaults to `/\r?\n/u`.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern = /\r?\n/u }) {
|
||||
this.ast = ast;
|
||||
this.text = text;
|
||||
// Remove the global(`g`) and sticky(`y`) flags from the `lineEndingPattern` to avoid issues with lastIndex.
|
||||
this.#lineEndingPattern = new RegExp(
|
||||
lineEndingPattern.source,
|
||||
lineEndingPattern.flags.replace(/[gy]/gu, ""),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the next line in the source text and updates `#lines` and `#lineStartIndices`.
|
||||
* @param {string} text The text to search for the next line.
|
||||
* @returns {boolean} `true` if a next line was found, `false` otherwise.
|
||||
*/
|
||||
#findNextLine(text) {
|
||||
const match = this.#lineEndingPattern.exec(text);
|
||||
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.#lines.push(text.slice(0, match.index));
|
||||
this.#lineStartIndices.push(
|
||||
(this.#lineStartIndices.at(-1) ?? 0) +
|
||||
match.index +
|
||||
match[0].length,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures `#lines` is lazily calculated from the source text.
|
||||
* @returns {void}
|
||||
*/
|
||||
#ensureLines() {
|
||||
// If `#lines` has already been calculated, do nothing.
|
||||
if (this.#lines.length === this.#lineStartIndices.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (
|
||||
this.#findNextLine(this.text.slice(this.#lineStartIndices.at(-1)))
|
||||
) {
|
||||
// Continue parsing until no more matches are found.
|
||||
}
|
||||
|
||||
this.#lines.push(this.text.slice(this.#lineStartIndices.at(-1)));
|
||||
|
||||
Object.freeze(this.#lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures `#lineStartIndices` is lazily calculated up to the specified index.
|
||||
* @param {number} index The index of a character in a file.
|
||||
* @returns {void}
|
||||
*/
|
||||
#ensureLineStartIndicesFromIndex(index) {
|
||||
// If we've already parsed up to or beyond this index, do nothing.
|
||||
if (index <= (this.#lineStartIndices.at(-1) ?? 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (
|
||||
index > (this.#lineStartIndices.at(-1) ?? 0) &&
|
||||
this.#findNextLine(this.text.slice(this.#lineStartIndices.at(-1)))
|
||||
) {
|
||||
// Continue parsing until no more matches are found.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures `#lineStartIndices` is lazily calculated up to the specified loc.
|
||||
* @param {Object} loc A line/column location.
|
||||
* @param {number} loc.line The line number of the location. (0 or 1-indexed based on language.)
|
||||
* @param {number} lineStart The line number at which the parser starts counting.
|
||||
* @returns {void}
|
||||
*/
|
||||
#ensureLineStartIndicesFromLoc(loc, lineStart) {
|
||||
// Calculate line indices up to the potentially next line, as it is needed for the follow‑up calculation.
|
||||
const nextLocLineIndex = loc.line - lineStart + 1;
|
||||
const lastCalculatedLineIndex = this.#lineStartIndices.length - 1;
|
||||
let additionalLinesNeeded = nextLocLineIndex - lastCalculatedLineIndex;
|
||||
|
||||
// If we've already parsed up to or beyond this line, do nothing.
|
||||
if (additionalLinesNeeded <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (
|
||||
additionalLinesNeeded > 0 &&
|
||||
this.#findNextLine(this.text.slice(this.#lineStartIndices.at(-1)))
|
||||
) {
|
||||
// Continue parsing until no more matches are found or we have enough lines.
|
||||
additionalLinesNeeded -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken) {
|
||||
if (hasESTreeStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.loc;
|
||||
}
|
||||
|
||||
if (hasPosStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.position;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getLoc() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a source text index into a `{ line: number, column: number }` pair.
|
||||
* @param {number} index The index of a character in a file.
|
||||
* @throws {TypeError|RangeError} If non-numeric index or index out of range.
|
||||
* @returns {{line: number, column: number}} A `{ line: number, column: number }` location object with 0 or 1-indexed line and 0 or 1-indexed column based on language.
|
||||
* @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}).`,
|
||||
);
|
||||
}
|
||||
|
||||
const {
|
||||
start: { line: lineStart, column: columnStart },
|
||||
end: { line: lineEnd, column: columnEnd },
|
||||
} = this.getLoc(this.ast);
|
||||
|
||||
// If the index is at the start, return the start location of the root node.
|
||||
if (index === 0) {
|
||||
return {
|
||||
line: lineStart,
|
||||
column: columnStart,
|
||||
};
|
||||
}
|
||||
|
||||
// If the index is `this.text.length`, return the location one "spot" past the last character of the file.
|
||||
if (index === this.text.length) {
|
||||
return {
|
||||
line: lineEnd,
|
||||
column: columnEnd,
|
||||
};
|
||||
}
|
||||
|
||||
// Ensure `#lineStartIndices` are lazily calculated.
|
||||
this.#ensureLineStartIndicesFromIndex(index);
|
||||
|
||||
/*
|
||||
* 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) ?? 0)
|
||||
? this.#lineStartIndices.length
|
||||
: findLineNumberBinarySearch(this.#lineStartIndices, index)) -
|
||||
1 +
|
||||
lineStart;
|
||||
|
||||
return {
|
||||
line: lineNumber,
|
||||
column:
|
||||
index -
|
||||
this.#lineStartIndices[lineNumber - lineStart] +
|
||||
columnStart,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a `{ line: number, column: number }` pair into a source text index.
|
||||
* @param {Object} loc A line/column location.
|
||||
* @param {number} loc.line The line number of the location. (0 or 1-indexed based on language.)
|
||||
* @param {number} loc.column The column number of the location. (0 or 1-indexed based on language.)
|
||||
* @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 index of the line/column location in a file.
|
||||
* @public
|
||||
*/
|
||||
getIndexFromLoc(loc) {
|
||||
if (
|
||||
loc === null ||
|
||||
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.",
|
||||
);
|
||||
}
|
||||
|
||||
const {
|
||||
start: { line: lineStart, column: columnStart },
|
||||
end: { line: lineEnd, column: columnEnd },
|
||||
} = this.getLoc(this.ast);
|
||||
|
||||
if (loc.line < lineStart || lineEnd < loc.line) {
|
||||
throw new RangeError(
|
||||
`Line number out of range (line ${loc.line} requested). Valid range: ${lineStart}-${lineEnd}`,
|
||||
);
|
||||
}
|
||||
|
||||
// If the loc is at the start, return the start index of the root node.
|
||||
if (loc.line === lineStart && loc.column === columnStart) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If the loc is at the end, return the index one "spot" past the last character of the file.
|
||||
if (loc.line === lineEnd && loc.column === columnEnd) {
|
||||
return this.text.length;
|
||||
}
|
||||
|
||||
// Ensure `#lineStartIndices` are lazily calculated.
|
||||
this.#ensureLineStartIndicesFromLoc(loc, lineStart);
|
||||
|
||||
const isLastLine = loc.line === lineEnd;
|
||||
const lineStartIndex = this.#lineStartIndices[loc.line - lineStart];
|
||||
const lineEndIndex = isLastLine
|
||||
? this.text.length
|
||||
: this.#lineStartIndices[loc.line - lineStart + 1];
|
||||
const positionIndex = lineStartIndex + loc.column - columnStart;
|
||||
|
||||
if (
|
||||
loc.column < columnStart ||
|
||||
(isLastLine && positionIndex > lineEndIndex) ||
|
||||
(!isLastLine && positionIndex >= lineEndIndex)
|
||||
) {
|
||||
throw new RangeError(
|
||||
`Column number out of range (column ${loc.column} requested). Valid range for line ${loc.line}: ${columnStart}-${lineEndIndex - lineStartIndex + columnStart + (isLastLine ? 0 : -1)}`,
|
||||
);
|
||||
}
|
||||
|
||||
return positionIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken) {
|
||||
if (hasESTreeStyleRange(nodeOrToken)) {
|
||||
return nodeOrToken.range;
|
||||
}
|
||||
|
||||
if (hasPosStyleRange(nodeOrToken)) {
|
||||
return [
|
||||
nodeOrToken.position.start.offset,
|
||||
nodeOrToken.position.end.offset,
|
||||
];
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getRange() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars -- Required to complete interface. */
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node) {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
/* eslint-enable no-unused-vars -- Required to complete interface. */
|
||||
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} 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 = this.getParent(node);
|
||||
ancestor;
|
||||
ancestor = this.getParent(ancestor)
|
||||
) {
|
||||
ancestorsStartingAtParent.push(ancestor);
|
||||
}
|
||||
|
||||
return ancestorsStartingAtParent.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [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) {
|
||||
const range = this.getRange(node);
|
||||
return this.text.slice(
|
||||
Math.max(range[0] - (beforeCount || 0), 0),
|
||||
range[1] + (afterCount || 0),
|
||||
);
|
||||
}
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
get lines() {
|
||||
this.#ensureLines(); // Ensure `#lines` is lazily calculated.
|
||||
|
||||
return this.#lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse() {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
exports.CallMethodStep = CallMethodStep;
|
||||
exports.ConfigCommentParser = ConfigCommentParser;
|
||||
exports.Directive = Directive;
|
||||
exports.TextSourceCodeBase = TextSourceCodeBase;
|
||||
exports.VisitNodeStep = VisitNodeStep;
|
||||
328
frontend/node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts
generated
vendored
Normal file
328
frontend/node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,328 @@
|
||||
export type VisitTraversalStep = $eslintcore.VisitTraversalStep;
|
||||
export type CallTraversalStep = $eslintcore.CallTraversalStep;
|
||||
export type TraversalStep = $eslintcore.TraversalStep;
|
||||
export type SourceLocation = $eslintcore.SourceLocation;
|
||||
export type SourceLocationWithOffset = $eslintcore.SourceLocationWithOffset;
|
||||
export type SourceRange = $eslintcore.SourceRange;
|
||||
export type IDirective = $eslintcore.Directive;
|
||||
export type DirectiveType = $eslintcore.DirectiveType;
|
||||
export type SourceCodeBaseTypeOptions = $eslintcore.SourceCodeBaseTypeOptions;
|
||||
/**
|
||||
* <Options>
|
||||
*/
|
||||
export type TextSourceCode<Options extends SourceCodeBaseTypeOptions = $eslintcore.SourceCodeBaseTypeOptions> = import("@eslint/core").TextSourceCode<Options>;
|
||||
export type RuleConfig = $eslintcore.RuleConfig;
|
||||
export type RulesConfig = $eslintcore.RulesConfig;
|
||||
export type StringConfig = $typests.StringConfig;
|
||||
export type BooleanConfig = $typests.BooleanConfig;
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
export class CallMethodStep implements CallTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }: {
|
||||
target: string;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "call";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 2;
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target: string;
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
export 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.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string: string): StringConfig;
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string: string): ({
|
||||
ok: true;
|
||||
config: RulesConfig;
|
||||
} | {
|
||||
ok: false;
|
||||
error: {
|
||||
message: string;
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string: string): BooleanConfig;
|
||||
/**
|
||||
* Parses a directive comment into directive text and value.
|
||||
* @param {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string: string): DirectiveComment | undefined;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
export class Directive implements IDirective {
|
||||
/**
|
||||
* 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 {unknown} 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 }: {
|
||||
type: "disable" | "enable" | "disable-next-line" | "disable-line";
|
||||
node: unknown;
|
||||
value: string;
|
||||
justification: string;
|
||||
});
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: DirectiveType;
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @readonly
|
||||
*/
|
||||
readonly node: unknown;
|
||||
/**
|
||||
* Everything after the "eslint-disable" portion of the directive,
|
||||
* but before the "--" that indicates the justification.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly value: string;
|
||||
/**
|
||||
* The justification for the directive.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly justification: string;
|
||||
}
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
export class TextSourceCodeBase<Options extends SourceCodeBaseTypeOptions & {
|
||||
RootNode: object;
|
||||
SyntaxElementWithLoc: object;
|
||||
} = $eslintcore.SourceCodeBaseTypeOptions & {
|
||||
RootNode: object;
|
||||
SyntaxElementWithLoc: object;
|
||||
}> implements TextSourceCode<Options> {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code. Defaults to `/\r?\n/u`.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern }: {
|
||||
text: string;
|
||||
ast: Options["RootNode"];
|
||||
lineEndingPattern?: RegExp;
|
||||
});
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast: Options["RootNode"];
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceLocation;
|
||||
/**
|
||||
* Converts a source text index into a `{ line: number, column: number }` pair.
|
||||
* @param {number} index The index of a character in a file.
|
||||
* @throws {TypeError|RangeError} If non-numeric index or index out of range.
|
||||
* @returns {{line: number, column: number}} A `{ line: number, column: number }` location object with 0 or 1-indexed line and 0 or 1-indexed column based on language.
|
||||
* @public
|
||||
*/
|
||||
public getLocFromIndex(index: number): {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
/**
|
||||
* Converts a `{ line: number, column: number }` pair into a source text index.
|
||||
* @param {Object} loc A line/column location.
|
||||
* @param {number} loc.line The line number of the location. (0 or 1-indexed based on language.)
|
||||
* @param {number} loc.column The column number of the location. (0 or 1-indexed based on language.)
|
||||
* @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 index of the line/column location in a file.
|
||||
* @public
|
||||
*/
|
||||
public getIndexFromLoc(loc: {
|
||||
line: number;
|
||||
column: number;
|
||||
}): number;
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceRange;
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node: Options["SyntaxElementWithLoc"]): Options["SyntaxElementWithLoc"] | undefined;
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} 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: Options["SyntaxElementWithLoc"]): Array<Options["SyntaxElementWithLoc"]>;
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
||||
* @returns {string} The text representing the AST node.
|
||||
* @public
|
||||
*/
|
||||
public getText(node?: Options["SyntaxElementWithLoc"], beforeCount?: number, afterCount?: number): string;
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
public get lines(): Array<string>;
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse(): Iterable<TraversalStep>;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
export class VisitNodeStep implements VisitTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }: {
|
||||
target: object;
|
||||
phase: 1 | 2;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "visit";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 1;
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target: object;
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase: 1 | 2;
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
import type * as $eslintcore from "@eslint/core";
|
||||
import type * as $typests from "./types.cts";
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
declare class DirectiveComment {
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label: string, value: string, justification: string);
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification: string;
|
||||
}
|
||||
export {};
|
||||
7
frontend/node_modules/@eslint/plugin-kit/dist/cjs/types.cts
generated
vendored
Normal file
7
frontend/node_modules/@eslint/plugin-kit/dist/cjs/types.cts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @fileoverview Types for the plugin-kit package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
export type StringConfig = Record<string, string | null>;
|
||||
export type BooleanConfig = Record<string, boolean>;
|
||||
328
frontend/node_modules/@eslint/plugin-kit/dist/esm/index.d.ts
generated
vendored
Normal file
328
frontend/node_modules/@eslint/plugin-kit/dist/esm/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,328 @@
|
||||
export type VisitTraversalStep = $eslintcore.VisitTraversalStep;
|
||||
export type CallTraversalStep = $eslintcore.CallTraversalStep;
|
||||
export type TraversalStep = $eslintcore.TraversalStep;
|
||||
export type SourceLocation = $eslintcore.SourceLocation;
|
||||
export type SourceLocationWithOffset = $eslintcore.SourceLocationWithOffset;
|
||||
export type SourceRange = $eslintcore.SourceRange;
|
||||
export type IDirective = $eslintcore.Directive;
|
||||
export type DirectiveType = $eslintcore.DirectiveType;
|
||||
export type SourceCodeBaseTypeOptions = $eslintcore.SourceCodeBaseTypeOptions;
|
||||
/**
|
||||
* <Options>
|
||||
*/
|
||||
export type TextSourceCode<Options extends SourceCodeBaseTypeOptions = $eslintcore.SourceCodeBaseTypeOptions> = import("@eslint/core").TextSourceCode<Options>;
|
||||
export type RuleConfig = $eslintcore.RuleConfig;
|
||||
export type RulesConfig = $eslintcore.RulesConfig;
|
||||
export type StringConfig = $typests.StringConfig;
|
||||
export type BooleanConfig = $typests.BooleanConfig;
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
export class CallMethodStep implements CallTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }: {
|
||||
target: string;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "call";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 2;
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target: string;
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
export 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.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string: string): StringConfig;
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string: string): ({
|
||||
ok: true;
|
||||
config: RulesConfig;
|
||||
} | {
|
||||
ok: false;
|
||||
error: {
|
||||
message: string;
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string: string): BooleanConfig;
|
||||
/**
|
||||
* Parses a directive comment into directive text and value.
|
||||
* @param {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string: string): DirectiveComment | undefined;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
export class Directive implements IDirective {
|
||||
/**
|
||||
* 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 {unknown} 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 }: {
|
||||
type: "disable" | "enable" | "disable-next-line" | "disable-line";
|
||||
node: unknown;
|
||||
value: string;
|
||||
justification: string;
|
||||
});
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: DirectiveType;
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @readonly
|
||||
*/
|
||||
readonly node: unknown;
|
||||
/**
|
||||
* Everything after the "eslint-disable" portion of the directive,
|
||||
* but before the "--" that indicates the justification.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly value: string;
|
||||
/**
|
||||
* The justification for the directive.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly justification: string;
|
||||
}
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
export class TextSourceCodeBase<Options extends SourceCodeBaseTypeOptions & {
|
||||
RootNode: object;
|
||||
SyntaxElementWithLoc: object;
|
||||
} = $eslintcore.SourceCodeBaseTypeOptions & {
|
||||
RootNode: object;
|
||||
SyntaxElementWithLoc: object;
|
||||
}> implements TextSourceCode<Options> {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code. Defaults to `/\r?\n/u`.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern }: {
|
||||
text: string;
|
||||
ast: Options["RootNode"];
|
||||
lineEndingPattern?: RegExp;
|
||||
});
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast: Options["RootNode"];
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceLocation;
|
||||
/**
|
||||
* Converts a source text index into a `{ line: number, column: number }` pair.
|
||||
* @param {number} index The index of a character in a file.
|
||||
* @throws {TypeError|RangeError} If non-numeric index or index out of range.
|
||||
* @returns {{line: number, column: number}} A `{ line: number, column: number }` location object with 0 or 1-indexed line and 0 or 1-indexed column based on language.
|
||||
* @public
|
||||
*/
|
||||
public getLocFromIndex(index: number): {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
/**
|
||||
* Converts a `{ line: number, column: number }` pair into a source text index.
|
||||
* @param {Object} loc A line/column location.
|
||||
* @param {number} loc.line The line number of the location. (0 or 1-indexed based on language.)
|
||||
* @param {number} loc.column The column number of the location. (0 or 1-indexed based on language.)
|
||||
* @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 index of the line/column location in a file.
|
||||
* @public
|
||||
*/
|
||||
public getIndexFromLoc(loc: {
|
||||
line: number;
|
||||
column: number;
|
||||
}): number;
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceRange;
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node: Options["SyntaxElementWithLoc"]): Options["SyntaxElementWithLoc"] | undefined;
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} 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: Options["SyntaxElementWithLoc"]): Array<Options["SyntaxElementWithLoc"]>;
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
||||
* @returns {string} The text representing the AST node.
|
||||
* @public
|
||||
*/
|
||||
public getText(node?: Options["SyntaxElementWithLoc"], beforeCount?: number, afterCount?: number): string;
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
public get lines(): Array<string>;
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse(): Iterable<TraversalStep>;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
export class VisitNodeStep implements VisitTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }: {
|
||||
target: object;
|
||||
phase: 1 | 2;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "visit";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 1;
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target: object;
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase: 1 | 2;
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
import type * as $eslintcore from "@eslint/core";
|
||||
import type * as $typests from "./types.ts";
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
declare class DirectiveComment {
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label: string, value: string, justification: string);
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification: string;
|
||||
}
|
||||
export {};
|
||||
879
frontend/node_modules/@eslint/plugin-kit/dist/esm/index.js
generated
vendored
Normal file
879
frontend/node_modules/@eslint/plugin-kit/dist/esm/index.js
generated
vendored
Normal file
@ -0,0 +1,879 @@
|
||||
// @ts-self-types="./index.d.ts"
|
||||
import levn from 'levn';
|
||||
|
||||
/**
|
||||
* @fileoverview Config Comment Parser
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @import * as $eslintcore from "@eslint/core"; */
|
||||
/** @typedef {$eslintcore.RuleConfig} RuleConfig */
|
||||
/** @typedef {$eslintcore.RulesConfig} RulesConfig */
|
||||
/** @import * as $typests from "./types.ts"; */
|
||||
/** @typedef {$typests.StringConfig} StringConfig */
|
||||
/** @typedef {$typests.BooleanConfig} BooleanConfig */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const directivesPattern = /^([a-z]+(?:-[a-z]+)*)(?:\s|$)/u;
|
||||
const validSeverities = new Set([0, 1, 2, "off", "warn", "error"]);
|
||||
|
||||
/**
|
||||
* Determines if the severity in the rule configuration is valid.
|
||||
* @param {RuleConfig} ruleConfig A rule's configuration.
|
||||
* @returns {boolean} `true` if the severity is valid, otherwise `false`.
|
||||
*/
|
||||
function isSeverityValid(ruleConfig) {
|
||||
const severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
|
||||
return validSeverities.has(severity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if all severities in the rules configuration are valid.
|
||||
* @param {RulesConfig} rulesConfig The rules configuration to check.
|
||||
* @returns {boolean} `true` if all severities are valid, otherwise `false`.
|
||||
*/
|
||||
function isEverySeverityValid(rulesConfig) {
|
||||
return Object.values(rulesConfig).every(isSeverityValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
class DirectiveComment {
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label = "";
|
||||
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value = "";
|
||||
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification = "";
|
||||
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label, value, justification) {
|
||||
this.label = label;
|
||||
this.value = value;
|
||||
this.justification = justification;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
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.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string) {
|
||||
const items = /** @type {StringConfig} */ ({});
|
||||
|
||||
// Collapse whitespace around `:` and `,` to make parsing easier
|
||||
const trimmedString = string
|
||||
.trim()
|
||||
.replace(/(?<!\s)\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;
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string) {
|
||||
// Parses a JSON-like comment by the same way as parsing CLI option.
|
||||
try {
|
||||
const items =
|
||||
/** @type {RulesConfig} */ (levn.parse("Object", string)) || {};
|
||||
|
||||
/*
|
||||
* When the configuration has any invalid severities, it should be completely
|
||||
* ignored. This is because the configuration is not valid and should not be
|
||||
* applied.
|
||||
*
|
||||
* For example, the following configuration is invalid:
|
||||
*
|
||||
* "no-alert: 2 no-console: 2"
|
||||
*
|
||||
* This results in a configuration of { "no-alert": "2 no-console: 2" }, which is
|
||||
* not valid. In this case, the configuration should be ignored.
|
||||
*/
|
||||
if (isEverySeverityValid(items)) {
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// levn parsing error: 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/])([-a-zA-Z0-9/]+):/gu, '"$1":')
|
||||
.replace(/([\]0-9])\s+(?=")/u, "$1,");
|
||||
|
||||
try {
|
||||
const items = JSON.parse(`{${normalizedString}}`);
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
} catch (ex) {
|
||||
const errorMessage = ex instanceof Error ? ex.message : String(ex);
|
||||
|
||||
return {
|
||||
ok: false,
|
||||
error: {
|
||||
message: `Failed to parse JSON from '${normalizedString}': ${errorMessage}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string) {
|
||||
const items = /** @type {BooleanConfig} */ ({});
|
||||
|
||||
string.split(",").forEach(name => {
|
||||
const trimmedName = name
|
||||
.trim()
|
||||
.replace(
|
||||
/^(?<quote>['"]?)(?<ruleId>.*)\k<quote>$/su,
|
||||
"$<ruleId>",
|
||||
);
|
||||
|
||||
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 {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string) {
|
||||
const { directivePart, justificationPart } =
|
||||
this.#extractDirectiveComment(string);
|
||||
const match = directivesPattern.exec(directivePart);
|
||||
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const directiveText = match[1];
|
||||
const directiveValue = directivePart.slice(
|
||||
match.index + directiveText.length,
|
||||
);
|
||||
|
||||
return new DirectiveComment(
|
||||
directiveText,
|
||||
directiveValue.trim(),
|
||||
justificationPart,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview A collection of helper classes for implementing `SourceCode`.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
/* eslint class-methods-use-this: off -- Required to complete interface. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {$eslintcore.VisitTraversalStep} VisitTraversalStep */
|
||||
/** @typedef {$eslintcore.CallTraversalStep} CallTraversalStep */
|
||||
/** @typedef {$eslintcore.TraversalStep} TraversalStep */
|
||||
/** @typedef {$eslintcore.SourceLocation} SourceLocation */
|
||||
/** @typedef {$eslintcore.SourceLocationWithOffset} SourceLocationWithOffset */
|
||||
/** @typedef {$eslintcore.SourceRange} SourceRange */
|
||||
/** @typedef {$eslintcore.Directive} IDirective */
|
||||
/** @typedef {$eslintcore.DirectiveType} DirectiveType */
|
||||
/** @typedef {$eslintcore.SourceCodeBaseTypeOptions} SourceCodeBaseTypeOptions */
|
||||
/**
|
||||
* @typedef {import("@eslint/core").TextSourceCode<Options>} TextSourceCode<Options>
|
||||
* @template {SourceCodeBaseTypeOptions} [Options=SourceCodeBaseTypeOptions]
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {loc:SourceLocation}} `true` if the node has ESTree-style loc information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleLoc(node) {
|
||||
return "loc" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocation}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleLoc(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {range:SourceRange}} `true` if the node has ESTree-style range information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleRange(node) {
|
||||
return "range" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocationWithOffset}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleRange(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs binary search to find the line number containing a given target index.
|
||||
* Returns the lower bound - the index of the first element greater than the target.
|
||||
* **Please note that the `lineStartIndices` should be sorted in ascending order**.
|
||||
* - Time Complexity: O(log n) - Significantly faster than linear search for large files.
|
||||
* @param {number[]} lineStartIndices Sorted array of line start indices.
|
||||
* @param {number} targetIndex The target index to find the line number for.
|
||||
* @returns {number} The line number for the target index.
|
||||
*/
|
||||
function findLineNumberBinarySearch(lineStartIndices, targetIndex) {
|
||||
let low = 0;
|
||||
let high = lineStartIndices.length - 1;
|
||||
|
||||
while (low < high) {
|
||||
const mid = ((low + high) / 2) | 0; // Use bitwise OR to floor the division.
|
||||
|
||||
if (targetIndex < lineStartIndices[mid]) {
|
||||
high = mid;
|
||||
} else {
|
||||
low = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
class VisitNodeStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "visit";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 1;
|
||||
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase;
|
||||
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }) {
|
||||
this.target = target;
|
||||
this.phase = phase;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
class CallMethodStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "call";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 2;
|
||||
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }) {
|
||||
this.target = target;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
class Directive {
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
type;
|
||||
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @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 {unknown} 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {RootNode: object, SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
class TextSourceCodeBase {
|
||||
/**
|
||||
* The lines of text in the source code.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
#lines = [];
|
||||
|
||||
/**
|
||||
* The indices of the start of each line in the source code.
|
||||
* @type {Array<number>}
|
||||
*/
|
||||
#lineStartIndices = [0];
|
||||
|
||||
/**
|
||||
* The pattern to match lineEndings in the source code.
|
||||
* @type {RegExp}
|
||||
*/
|
||||
#lineEndingPattern;
|
||||
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast;
|
||||
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code. Defaults to `/\r?\n/u`.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern = /\r?\n/u }) {
|
||||
this.ast = ast;
|
||||
this.text = text;
|
||||
// Remove the global(`g`) and sticky(`y`) flags from the `lineEndingPattern` to avoid issues with lastIndex.
|
||||
this.#lineEndingPattern = new RegExp(
|
||||
lineEndingPattern.source,
|
||||
lineEndingPattern.flags.replace(/[gy]/gu, ""),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the next line in the source text and updates `#lines` and `#lineStartIndices`.
|
||||
* @param {string} text The text to search for the next line.
|
||||
* @returns {boolean} `true` if a next line was found, `false` otherwise.
|
||||
*/
|
||||
#findNextLine(text) {
|
||||
const match = this.#lineEndingPattern.exec(text);
|
||||
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.#lines.push(text.slice(0, match.index));
|
||||
this.#lineStartIndices.push(
|
||||
(this.#lineStartIndices.at(-1) ?? 0) +
|
||||
match.index +
|
||||
match[0].length,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures `#lines` is lazily calculated from the source text.
|
||||
* @returns {void}
|
||||
*/
|
||||
#ensureLines() {
|
||||
// If `#lines` has already been calculated, do nothing.
|
||||
if (this.#lines.length === this.#lineStartIndices.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (
|
||||
this.#findNextLine(this.text.slice(this.#lineStartIndices.at(-1)))
|
||||
) {
|
||||
// Continue parsing until no more matches are found.
|
||||
}
|
||||
|
||||
this.#lines.push(this.text.slice(this.#lineStartIndices.at(-1)));
|
||||
|
||||
Object.freeze(this.#lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures `#lineStartIndices` is lazily calculated up to the specified index.
|
||||
* @param {number} index The index of a character in a file.
|
||||
* @returns {void}
|
||||
*/
|
||||
#ensureLineStartIndicesFromIndex(index) {
|
||||
// If we've already parsed up to or beyond this index, do nothing.
|
||||
if (index <= (this.#lineStartIndices.at(-1) ?? 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (
|
||||
index > (this.#lineStartIndices.at(-1) ?? 0) &&
|
||||
this.#findNextLine(this.text.slice(this.#lineStartIndices.at(-1)))
|
||||
) {
|
||||
// Continue parsing until no more matches are found.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures `#lineStartIndices` is lazily calculated up to the specified loc.
|
||||
* @param {Object} loc A line/column location.
|
||||
* @param {number} loc.line The line number of the location. (0 or 1-indexed based on language.)
|
||||
* @param {number} lineStart The line number at which the parser starts counting.
|
||||
* @returns {void}
|
||||
*/
|
||||
#ensureLineStartIndicesFromLoc(loc, lineStart) {
|
||||
// Calculate line indices up to the potentially next line, as it is needed for the follow‑up calculation.
|
||||
const nextLocLineIndex = loc.line - lineStart + 1;
|
||||
const lastCalculatedLineIndex = this.#lineStartIndices.length - 1;
|
||||
let additionalLinesNeeded = nextLocLineIndex - lastCalculatedLineIndex;
|
||||
|
||||
// If we've already parsed up to or beyond this line, do nothing.
|
||||
if (additionalLinesNeeded <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (
|
||||
additionalLinesNeeded > 0 &&
|
||||
this.#findNextLine(this.text.slice(this.#lineStartIndices.at(-1)))
|
||||
) {
|
||||
// Continue parsing until no more matches are found or we have enough lines.
|
||||
additionalLinesNeeded -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken) {
|
||||
if (hasESTreeStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.loc;
|
||||
}
|
||||
|
||||
if (hasPosStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.position;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getLoc() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a source text index into a `{ line: number, column: number }` pair.
|
||||
* @param {number} index The index of a character in a file.
|
||||
* @throws {TypeError|RangeError} If non-numeric index or index out of range.
|
||||
* @returns {{line: number, column: number}} A `{ line: number, column: number }` location object with 0 or 1-indexed line and 0 or 1-indexed column based on language.
|
||||
* @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}).`,
|
||||
);
|
||||
}
|
||||
|
||||
const {
|
||||
start: { line: lineStart, column: columnStart },
|
||||
end: { line: lineEnd, column: columnEnd },
|
||||
} = this.getLoc(this.ast);
|
||||
|
||||
// If the index is at the start, return the start location of the root node.
|
||||
if (index === 0) {
|
||||
return {
|
||||
line: lineStart,
|
||||
column: columnStart,
|
||||
};
|
||||
}
|
||||
|
||||
// If the index is `this.text.length`, return the location one "spot" past the last character of the file.
|
||||
if (index === this.text.length) {
|
||||
return {
|
||||
line: lineEnd,
|
||||
column: columnEnd,
|
||||
};
|
||||
}
|
||||
|
||||
// Ensure `#lineStartIndices` are lazily calculated.
|
||||
this.#ensureLineStartIndicesFromIndex(index);
|
||||
|
||||
/*
|
||||
* 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) ?? 0)
|
||||
? this.#lineStartIndices.length
|
||||
: findLineNumberBinarySearch(this.#lineStartIndices, index)) -
|
||||
1 +
|
||||
lineStart;
|
||||
|
||||
return {
|
||||
line: lineNumber,
|
||||
column:
|
||||
index -
|
||||
this.#lineStartIndices[lineNumber - lineStart] +
|
||||
columnStart,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a `{ line: number, column: number }` pair into a source text index.
|
||||
* @param {Object} loc A line/column location.
|
||||
* @param {number} loc.line The line number of the location. (0 or 1-indexed based on language.)
|
||||
* @param {number} loc.column The column number of the location. (0 or 1-indexed based on language.)
|
||||
* @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 index of the line/column location in a file.
|
||||
* @public
|
||||
*/
|
||||
getIndexFromLoc(loc) {
|
||||
if (
|
||||
loc === null ||
|
||||
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.",
|
||||
);
|
||||
}
|
||||
|
||||
const {
|
||||
start: { line: lineStart, column: columnStart },
|
||||
end: { line: lineEnd, column: columnEnd },
|
||||
} = this.getLoc(this.ast);
|
||||
|
||||
if (loc.line < lineStart || lineEnd < loc.line) {
|
||||
throw new RangeError(
|
||||
`Line number out of range (line ${loc.line} requested). Valid range: ${lineStart}-${lineEnd}`,
|
||||
);
|
||||
}
|
||||
|
||||
// If the loc is at the start, return the start index of the root node.
|
||||
if (loc.line === lineStart && loc.column === columnStart) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If the loc is at the end, return the index one "spot" past the last character of the file.
|
||||
if (loc.line === lineEnd && loc.column === columnEnd) {
|
||||
return this.text.length;
|
||||
}
|
||||
|
||||
// Ensure `#lineStartIndices` are lazily calculated.
|
||||
this.#ensureLineStartIndicesFromLoc(loc, lineStart);
|
||||
|
||||
const isLastLine = loc.line === lineEnd;
|
||||
const lineStartIndex = this.#lineStartIndices[loc.line - lineStart];
|
||||
const lineEndIndex = isLastLine
|
||||
? this.text.length
|
||||
: this.#lineStartIndices[loc.line - lineStart + 1];
|
||||
const positionIndex = lineStartIndex + loc.column - columnStart;
|
||||
|
||||
if (
|
||||
loc.column < columnStart ||
|
||||
(isLastLine && positionIndex > lineEndIndex) ||
|
||||
(!isLastLine && positionIndex >= lineEndIndex)
|
||||
) {
|
||||
throw new RangeError(
|
||||
`Column number out of range (column ${loc.column} requested). Valid range for line ${loc.line}: ${columnStart}-${lineEndIndex - lineStartIndex + columnStart + (isLastLine ? 0 : -1)}`,
|
||||
);
|
||||
}
|
||||
|
||||
return positionIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken) {
|
||||
if (hasESTreeStyleRange(nodeOrToken)) {
|
||||
return nodeOrToken.range;
|
||||
}
|
||||
|
||||
if (hasPosStyleRange(nodeOrToken)) {
|
||||
return [
|
||||
nodeOrToken.position.start.offset,
|
||||
nodeOrToken.position.end.offset,
|
||||
];
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getRange() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars -- Required to complete interface. */
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node) {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
/* eslint-enable no-unused-vars -- Required to complete interface. */
|
||||
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} 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 = this.getParent(node);
|
||||
ancestor;
|
||||
ancestor = this.getParent(ancestor)
|
||||
) {
|
||||
ancestorsStartingAtParent.push(ancestor);
|
||||
}
|
||||
|
||||
return ancestorsStartingAtParent.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [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) {
|
||||
const range = this.getRange(node);
|
||||
return this.text.slice(
|
||||
Math.max(range[0] - (beforeCount || 0), 0),
|
||||
range[1] + (afterCount || 0),
|
||||
);
|
||||
}
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
get lines() {
|
||||
this.#ensureLines(); // Ensure `#lines` is lazily calculated.
|
||||
|
||||
return this.#lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse() {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
export { CallMethodStep, ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep };
|
||||
6
frontend/node_modules/@eslint/plugin-kit/dist/esm/types.d.ts
generated
vendored
Normal file
6
frontend/node_modules/@eslint/plugin-kit/dist/esm/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @fileoverview Types for the plugin-kit package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
export type StringConfig = Record<string, string | null>;
|
||||
export type BooleanConfig = Record<string, boolean>;
|
||||
7
frontend/node_modules/@eslint/plugin-kit/dist/esm/types.ts
generated
vendored
Normal file
7
frontend/node_modules/@eslint/plugin-kit/dist/esm/types.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @fileoverview Types for the plugin-kit package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
export type StringConfig = Record<string, string | null>;
|
||||
export type BooleanConfig = Record<string, boolean>;
|
||||
61
frontend/node_modules/@eslint/plugin-kit/package.json
generated
vendored
Normal file
61
frontend/node_modules/@eslint/plugin-kit/package.json
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "@eslint/plugin-kit",
|
||||
"version": "0.4.1",
|
||||
"description": "Utilities for building ESLint plugins.",
|
||||
"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",
|
||||
"directory": "packages/plugin-kit"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite/tree/main/packages/plugin-kit#readme",
|
||||
"scripts": {
|
||||
"build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
||||
"build:cts": "node ../../tools/build-cts.js 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",
|
||||
"pretest": "npm run build",
|
||||
"test": "mocha \"tests/**/*.test.js\"",
|
||||
"test:coverage": "c8 npm test",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"test:types": "tsc -p tests/types/tsconfig.json"
|
||||
},
|
||||
"keywords": [
|
||||
"eslint",
|
||||
"eslintplugin",
|
||||
"eslint-plugin"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@eslint/core": "^0.17.0",
|
||||
"levn": "^0.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/levn": "^0.4.0",
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user