initial commit of actions
This commit is contained in:
commit
949ece5785
44660 changed files with 12034344 additions and 0 deletions
201
github/codeql-action-v2/node_modules/@eslint/compat/LICENSE
generated
vendored
Normal file
201
github/codeql-action-v2/node_modules/@eslint/compat/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.
|
||||
207
github/codeql-action-v2/node_modules/@eslint/compat/README.md
generated
vendored
Normal file
207
github/codeql-action-v2/node_modules/@eslint/compat/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
# ESLint Compatibility Utilities
|
||||
|
||||
## Overview
|
||||
|
||||
This packages contains functions that allow you to wrap existing ESLint rules, plugins, and configurations that were intended for use with ESLint v8.x to allow them to work as-is in ESLint v9.x.
|
||||
|
||||
**Note:** All plugins are not guaranteed to work in ESLint v9.x. This package fixes the most common issues but can't fix everything.
|
||||
|
||||
## Installation
|
||||
|
||||
For Node.js and compatible runtimes:
|
||||
|
||||
```shell
|
||||
npm install @eslint/compat -D
|
||||
# or
|
||||
yarn add @eslint/compat -D
|
||||
# or
|
||||
pnpm install @eslint/compat -D
|
||||
# or
|
||||
bun install @eslint/compat -D
|
||||
```
|
||||
|
||||
For Deno:
|
||||
|
||||
```shell
|
||||
deno add @eslint/compat
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This package exports the following functions in both ESM and CommonJS format:
|
||||
|
||||
- `fixupRule(rule)` - wraps the given rule in a compatibility layer and returns the result
|
||||
- `fixupPluginRules(plugin)` - wraps each rule in the given plugin using `fixupRule()` and returns a new object that represents the plugin with the fixed-up rules
|
||||
- `fixupConfigRules(configs)` - wraps all plugins found in an array of config objects using `fixupPluginRules()`
|
||||
- `includeIgnoreFile(path)` - reads an ignore file (like `.gitignore`) and converts the patterns into the correct format for the config file
|
||||
|
||||
### Fixing Rules
|
||||
|
||||
If you have a rule that you'd like to make compatible with ESLint v9.x, you can do so using the `fixupRule()` function:
|
||||
|
||||
```js
|
||||
// ESM example
|
||||
import { fixupRule } from "@eslint/compat";
|
||||
|
||||
// Step 1: Import your rule
|
||||
import myRule from "./local-rule.js";
|
||||
|
||||
// Step 2: Create backwards-compatible rule
|
||||
const compatRule = fixupRule(myRule);
|
||||
|
||||
// Step 3 (optional): Export fixed rule
|
||||
export default compatRule;
|
||||
```
|
||||
|
||||
Or in CommonJS:
|
||||
|
||||
```js
|
||||
// CommonJS example
|
||||
const { fixupRule } = require("@eslint/compat");
|
||||
|
||||
// Step 1: Import your rule
|
||||
const myRule = require("./local-rule.js");
|
||||
|
||||
// Step 2: Create backwards-compatible rule
|
||||
const compatRule = fixupRule(myRule);
|
||||
|
||||
// Step 3 (optional): Export fixed rule
|
||||
module.exports = compatRule;
|
||||
```
|
||||
|
||||
### Fixing Plugins
|
||||
|
||||
If you are using a plugin in your `eslint.config.js` that is not yet compatible with ESLint 9.x, you can wrap it using the `fixupPluginRules()` function:
|
||||
|
||||
```js
|
||||
// eslint.config.js - ESM example
|
||||
import { fixupPluginRules } from "@eslint/compat";
|
||||
import somePlugin from "eslint-plugin-some-plugin";
|
||||
|
||||
export default [
|
||||
{
|
||||
plugins: {
|
||||
// insert the fixed plugin instead of the original
|
||||
somePlugin: fixupPluginRules(somePlugin),
|
||||
},
|
||||
rules: {
|
||||
"somePlugin/rule-name": "error",
|
||||
},
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
Or in CommonJS:
|
||||
|
||||
```js
|
||||
// eslint.config.js - CommonJS example
|
||||
const { fixupPluginRules } = require("@eslint/compat");
|
||||
const somePlugin = require("eslint-plugin-some-plugin");
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
plugins: {
|
||||
// insert the fixed plugin instead of the original
|
||||
somePlugin: fixupPluginRules(somePlugin),
|
||||
},
|
||||
rules: {
|
||||
"somePlugin/rule-name": "error",
|
||||
},
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### Fixing Configs
|
||||
|
||||
If you are importing other configs into your `eslint.config.js` that use plugins that are not yet compatible with ESLint 9.x, you can wrap the entire array or a single object using the `fixupConfigRules()` function:
|
||||
|
||||
```js
|
||||
// eslint.config.js - ESM example
|
||||
import { fixupConfigRules } from "@eslint/compat";
|
||||
import someConfig from "eslint-config-some-config";
|
||||
|
||||
export default [
|
||||
...fixupConfigRules(someConfig),
|
||||
{
|
||||
// your overrides
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
Or in CommonJS:
|
||||
|
||||
```js
|
||||
// eslint.config.js - CommonJS example
|
||||
const { fixupConfigRules } = require("@eslint/compat");
|
||||
const someConfig = require("eslint-config-some-config");
|
||||
|
||||
module.exports = [
|
||||
...fixupConfigRules(someConfig),
|
||||
{
|
||||
// your overrides
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### Including Ignore Files
|
||||
|
||||
If you were using an alternate ignore file in ESLint v8.x, such as using `--ignore-path .gitignore` on the command line, you can include those patterns programmatically in your config file using the `includeIgnoreFile()` function. For example:
|
||||
|
||||
```js
|
||||
// eslint.config.js - ESM example
|
||||
import { includeIgnoreFile } from "@eslint/compat";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const gitignorePath = path.resolve(__dirname, ".gitignore");
|
||||
|
||||
export default [
|
||||
includeIgnoreFile(gitignorePath),
|
||||
{
|
||||
// your overrides
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
Or in CommonJS:
|
||||
|
||||
```js
|
||||
// eslint.config.js - CommonJS example
|
||||
const { includeIgnoreFile } = require("@eslint/compat");
|
||||
const path = require("node:path");
|
||||
const gitignorePath = path.resolve(__dirname, ".gitignore");
|
||||
|
||||
module.exports = [
|
||||
includeIgnoreFile(gitignorePath),
|
||||
{
|
||||
// your overrides
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
**Limitation:** This works without modification when the ignore file is in the same directory as your config file. If the ignore file is in a different directory, you may need to modify the patterns manually.
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
## 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 README and website.
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
<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="#"><img src="https://images.opencollective.com/guest-bf377e88/avatar.png" alt="Eli Schleifer" height="96"></a> <a href="https://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" 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?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<p><a href="https://www.notion.so"><img src="https://images.opencollective.com/notion/bf3b117/logo.png" alt="notion" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p>
|
||||
<!--sponsorsend-->
|
||||
|
||||
<!--techsponsorsstart-->
|
||||
<h2>Technology Sponsors</h2>
|
||||
<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>
|
||||
<!--techsponsorsend-->
|
||||
351
github/codeql-action-v2/node_modules/@eslint/compat/dist/cjs/index.cjs
generated
vendored
Normal file
351
github/codeql-action-v2/node_modules/@eslint/compat/dist/cjs/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,351 @@
|
|||
'use strict';
|
||||
|
||||
var fs = require('node:fs');
|
||||
var path = require('node:path');
|
||||
|
||||
/**
|
||||
* @filedescription Functions to fix up rules to provide missing methods on the `context` object.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint").ESLint.Plugin} FixupPluginDefinition */
|
||||
/** @typedef {import("eslint").Rule.RuleModule} FixupRuleDefinition */
|
||||
/** @typedef {import("eslint").Rule.OldStyleRule} FixupLegacyRuleDefinition */
|
||||
/** @typedef {import("eslint").Linter.FlatConfig} FixupConfig */
|
||||
/** @typedef {Array<FixupConfig>} FixupConfigArray */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The removed methods from the `context` object that need to be added back.
|
||||
* The keys are the name of the method on the `context` object and the values
|
||||
* are the name of the method on the `sourceCode` object.
|
||||
* @type {Map<string, string>}
|
||||
*/
|
||||
const removedMethodNames = new Map([
|
||||
["getSource", "getText"],
|
||||
["getSourceLines", "getLines"],
|
||||
["getAllComments", "getAllComments"],
|
||||
["getDeclaredVariables", "getDeclaredVariables"],
|
||||
["getNodeByRangeIndex", "getNodeByRangeIndex"],
|
||||
["getCommentsBefore", "getCommentsBefore"],
|
||||
["getCommentsAfter", "getCommentsAfter"],
|
||||
["getCommentsInside", "getCommentsInside"],
|
||||
["getJSDocComment", "getJSDocComment"],
|
||||
["getFirstToken", "getFirstToken"],
|
||||
["getFirstTokens", "getFirstTokens"],
|
||||
["getLastToken", "getLastToken"],
|
||||
["getLastTokens", "getLastTokens"],
|
||||
["getTokenAfter", "getTokenAfter"],
|
||||
["getTokenBefore", "getTokenBefore"],
|
||||
["getTokenByRangeStart", "getTokenByRangeStart"],
|
||||
["getTokens", "getTokens"],
|
||||
["getTokensAfter", "getTokensAfter"],
|
||||
["getTokensBefore", "getTokensBefore"],
|
||||
["getTokensBetween", "getTokensBetween"],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Tracks the original rule definition and the fixed-up rule definition.
|
||||
* @type {WeakMap<FixupRuleDefinition|FixupLegacyRuleDefinition,FixupRuleDefinition>}
|
||||
*/
|
||||
const fixedUpRuleReplacements = new WeakMap();
|
||||
|
||||
/**
|
||||
* Tracks all of the fixed up rule definitions so we don't duplicate effort.
|
||||
* @type {WeakSet<FixupRuleDefinition>}
|
||||
*/
|
||||
const fixedUpRules = new WeakSet();
|
||||
|
||||
/**
|
||||
* Tracks the original plugin definition and the fixed-up plugin definition.
|
||||
* @type {WeakMap<FixupPluginDefinition,FixupPluginDefinition>}
|
||||
*/
|
||||
const fixedUpPluginReplacements = new WeakMap();
|
||||
|
||||
/**
|
||||
* Tracks all of the fixed up plugin definitions so we don't duplicate effort.
|
||||
* @type {WeakSet<FixupPluginDefinition>}
|
||||
*/
|
||||
const fixedUpPlugins = new WeakSet();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Takes the given rule and creates a new rule with the `create()` method wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupRuleDefinition|FixupLegacyRuleDefinition} ruleDefinition The rule to fix up.
|
||||
* @returns {FixupRuleDefinition} The fixed-up rule.
|
||||
*/
|
||||
function fixupRule(ruleDefinition) {
|
||||
// first check if we've already fixed up this rule
|
||||
if (fixedUpRuleReplacements.has(ruleDefinition)) {
|
||||
return fixedUpRuleReplacements.get(ruleDefinition);
|
||||
}
|
||||
|
||||
const isLegacyRule = typeof ruleDefinition === "function";
|
||||
|
||||
// check to see if this rule definition has already been fixed up
|
||||
if (!isLegacyRule && fixedUpRules.has(ruleDefinition)) {
|
||||
return ruleDefinition;
|
||||
}
|
||||
|
||||
const originalCreate = isLegacyRule
|
||||
? ruleDefinition
|
||||
: ruleDefinition.create.bind(ruleDefinition);
|
||||
|
||||
function ruleCreate(context) {
|
||||
// if getScope is already there then no need to create old methods
|
||||
if ("getScope" in context) {
|
||||
return originalCreate(context);
|
||||
}
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
let currentNode = sourceCode.ast;
|
||||
|
||||
const newContext = Object.assign(Object.create(context), {
|
||||
parserServices: sourceCode.parserServices,
|
||||
|
||||
/*
|
||||
* The following methods rely on the current node in the traversal,
|
||||
* so we need to add them manually.
|
||||
*/
|
||||
getScope() {
|
||||
return sourceCode.getScope(currentNode);
|
||||
},
|
||||
|
||||
getAncestors() {
|
||||
return sourceCode.getAncestors(currentNode);
|
||||
},
|
||||
|
||||
markVariableAsUsed(variable) {
|
||||
sourceCode.markVariableAsUsed(variable, currentNode);
|
||||
},
|
||||
});
|
||||
|
||||
// add passthrough methods
|
||||
for (const [
|
||||
contextMethodName,
|
||||
sourceCodeMethodName,
|
||||
] of removedMethodNames) {
|
||||
newContext[contextMethodName] =
|
||||
sourceCode[sourceCodeMethodName].bind(sourceCode);
|
||||
}
|
||||
|
||||
// freeze just like the original context
|
||||
Object.freeze(newContext);
|
||||
|
||||
/*
|
||||
* Create the visitor object using the original create() method.
|
||||
* This is necessary to ensure that the visitor object is created
|
||||
* with the correct context.
|
||||
*/
|
||||
const visitor = originalCreate(newContext);
|
||||
|
||||
/*
|
||||
* Wrap each method in the visitor object to update the currentNode
|
||||
* before calling the original method. This is necessary because the
|
||||
* methods like `getScope()` need to know the current node.
|
||||
*/
|
||||
for (const [methodName, method] of Object.entries(visitor)) {
|
||||
/*
|
||||
* Node is the second argument to most code path methods,
|
||||
* and the third argument for onCodePathSegmentLoop.
|
||||
*/
|
||||
if (methodName.startsWith("on")) {
|
||||
// eslint-disable-next-line no-loop-func -- intentionally updating shared `currentNode` variable
|
||||
visitor[methodName] = (...args) => {
|
||||
currentNode =
|
||||
args[methodName === "onCodePathSegmentLoop" ? 2 : 1];
|
||||
|
||||
return method.call(visitor, ...args);
|
||||
};
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-loop-func -- intentionally updating shared `currentNode` variable
|
||||
visitor[methodName] = (...args) => {
|
||||
currentNode = args[0];
|
||||
|
||||
return method.call(visitor, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
return visitor;
|
||||
}
|
||||
|
||||
const newRuleDefinition = {
|
||||
...(isLegacyRule ? undefined : ruleDefinition),
|
||||
create: ruleCreate,
|
||||
};
|
||||
|
||||
// cache the fixed up rule
|
||||
fixedUpRuleReplacements.set(ruleDefinition, newRuleDefinition);
|
||||
fixedUpRules.add(newRuleDefinition);
|
||||
|
||||
return newRuleDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the given plugin and creates a new plugin with all of the rules wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupPluginDefinition} plugin The plugin to fix up.
|
||||
* @returns {FixupPluginDefinition} The fixed-up plugin.
|
||||
*/
|
||||
function fixupPluginRules(plugin) {
|
||||
// first check if we've already fixed up this plugin
|
||||
if (fixedUpPluginReplacements.has(plugin)) {
|
||||
return fixedUpPluginReplacements.get(plugin);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the plugin has already been fixed up, or if the plugin
|
||||
* doesn't have any rules, we can just return it.
|
||||
*/
|
||||
if (fixedUpPlugins.has(plugin) || !plugin.rules) {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
const newPlugin = {
|
||||
...plugin,
|
||||
rules: Object.fromEntries(
|
||||
Object.entries(plugin.rules).map(([ruleId, ruleDefinition]) => [
|
||||
ruleId,
|
||||
fixupRule(ruleDefinition),
|
||||
]),
|
||||
),
|
||||
};
|
||||
|
||||
// cache the fixed up plugin
|
||||
fixedUpPluginReplacements.set(plugin, newPlugin);
|
||||
fixedUpPlugins.add(newPlugin);
|
||||
|
||||
return newPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the given configuration and creates a new configuration with all of the
|
||||
* rules wrapped to provide the missing methods on the `context` object.
|
||||
* @param {FixupConfigArray|FixupConfig} config The configuration to fix up.
|
||||
* @returns {FixupConfigArray} The fixed-up configuration.
|
||||
*/
|
||||
function fixupConfigRules(config) {
|
||||
const configs = Array.isArray(config) ? config : [config];
|
||||
|
||||
return configs.map(configItem => {
|
||||
if (!configItem.plugins) {
|
||||
return configItem;
|
||||
}
|
||||
|
||||
const newPlugins = Object.fromEntries(
|
||||
Object.entries(configItem.plugins).map(([pluginName, plugin]) => [
|
||||
pluginName,
|
||||
fixupPluginRules(plugin),
|
||||
]),
|
||||
);
|
||||
|
||||
return {
|
||||
...configItem,
|
||||
plugins: newPlugins,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Ignore file utilities for the compat package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint").Linter.FlatConfig} FlatConfig */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Converts an ESLint ignore pattern to a minimatch pattern.
|
||||
* @param {string} pattern The .eslintignore or .gitignore pattern to convert.
|
||||
* @returns {string} The converted pattern.
|
||||
*/
|
||||
function convertIgnorePatternToMinimatch(pattern) {
|
||||
const isNegated = pattern.startsWith("!");
|
||||
const negatedPrefix = isNegated ? "!" : "";
|
||||
const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd();
|
||||
|
||||
// special cases
|
||||
if (["", "**", "/**", "**/"].includes(patternToTest)) {
|
||||
return `${negatedPrefix}${patternToTest}`;
|
||||
}
|
||||
|
||||
const firstIndexOfSlash = patternToTest.indexOf("/");
|
||||
|
||||
const matchEverywherePrefix =
|
||||
firstIndexOfSlash < 0 || firstIndexOfSlash === patternToTest.length - 1
|
||||
? "**/"
|
||||
: "";
|
||||
|
||||
const patternWithoutLeadingSlash =
|
||||
firstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest;
|
||||
|
||||
/*
|
||||
* Escape `{` and `(` because in gitignore patterns they are just
|
||||
* literal characters without any specific syntactic meaning,
|
||||
* while in minimatch patterns they can form brace expansion or extglob syntax.
|
||||
*
|
||||
* For example, gitignore pattern `src/{a,b}.js` ignores file `src/{a,b}.js`.
|
||||
* But, the same minimatch pattern `src/{a,b}.js` ignores files `src/a.js` and `src/b.js`.
|
||||
* Minimatch pattern `src/\{a,b}.js` is equivalent to gitignore pattern `src/{a,b}.js`.
|
||||
*/
|
||||
const escapedPatternWithoutLeadingSlash =
|
||||
patternWithoutLeadingSlash.replaceAll(
|
||||
/(?=((?:\\.|[^{(])*))\1([{(])/guy,
|
||||
"$1\\$2",
|
||||
);
|
||||
|
||||
const matchInsideSuffix = patternToTest.endsWith("/**") ? "/*" : "";
|
||||
|
||||
return `${negatedPrefix}${matchEverywherePrefix}${escapedPatternWithoutLeadingSlash}${matchInsideSuffix}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an ignore file and returns an object with the ignore patterns.
|
||||
* @param {string} ignoreFilePath The absolute path to the ignore file.
|
||||
* @returns {FlatConfig} An object with an `ignores` property that is an array of ignore patterns.
|
||||
* @throws {Error} If the ignore file path is not an absolute path.
|
||||
*/
|
||||
function includeIgnoreFile(ignoreFilePath) {
|
||||
if (!path.isAbsolute(ignoreFilePath)) {
|
||||
throw new Error("The ignore file location must be an absolute path.");
|
||||
}
|
||||
|
||||
const ignoreFile = fs.readFileSync(ignoreFilePath, "utf8");
|
||||
const lines = ignoreFile.split(/\r?\n/u);
|
||||
|
||||
return {
|
||||
name: "Imported .gitignore patterns",
|
||||
ignores: lines
|
||||
.map(line => line.trim())
|
||||
.filter(line => line && !line.startsWith("#"))
|
||||
.map(convertIgnorePatternToMinimatch),
|
||||
};
|
||||
}
|
||||
|
||||
exports.convertIgnorePatternToMinimatch = convertIgnorePatternToMinimatch;
|
||||
exports.fixupConfigRules = fixupConfigRules;
|
||||
exports.fixupPluginRules = fixupPluginRules;
|
||||
exports.fixupRule = fixupRule;
|
||||
exports.includeIgnoreFile = includeIgnoreFile;
|
||||
45
github/codeql-action-v2/node_modules/@eslint/compat/dist/cjs/index.d.cts
generated
vendored
Normal file
45
github/codeql-action-v2/node_modules/@eslint/compat/dist/cjs/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
export type FlatConfig = import("eslint").Linter.FlatConfig;
|
||||
export type FixupPluginDefinition = import("eslint").ESLint.Plugin;
|
||||
export type FixupRuleDefinition = import("eslint").Rule.RuleModule;
|
||||
export type FixupLegacyRuleDefinition = import("eslint").Rule.OldStyleRule;
|
||||
export type FixupConfig = import("eslint").Linter.FlatConfig;
|
||||
export type FixupConfigArray = Array<FixupConfig>;
|
||||
/**
|
||||
* @fileoverview Ignore file utilities for the compat package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
/** @typedef {import("eslint").Linter.FlatConfig} FlatConfig */
|
||||
/**
|
||||
* Converts an ESLint ignore pattern to a minimatch pattern.
|
||||
* @param {string} pattern The .eslintignore or .gitignore pattern to convert.
|
||||
* @returns {string} The converted pattern.
|
||||
*/
|
||||
export function convertIgnorePatternToMinimatch(pattern: string): string;
|
||||
/**
|
||||
* Takes the given configuration and creates a new configuration with all of the
|
||||
* rules wrapped to provide the missing methods on the `context` object.
|
||||
* @param {FixupConfigArray|FixupConfig} config The configuration to fix up.
|
||||
* @returns {FixupConfigArray} The fixed-up configuration.
|
||||
*/
|
||||
export function fixupConfigRules(config: FixupConfigArray | FixupConfig): FixupConfigArray;
|
||||
/**
|
||||
* Takes the given plugin and creates a new plugin with all of the rules wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupPluginDefinition} plugin The plugin to fix up.
|
||||
* @returns {FixupPluginDefinition} The fixed-up plugin.
|
||||
*/
|
||||
export function fixupPluginRules(plugin: FixupPluginDefinition): FixupPluginDefinition;
|
||||
/**
|
||||
* Takes the given rule and creates a new rule with the `create()` method wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupRuleDefinition|FixupLegacyRuleDefinition} ruleDefinition The rule to fix up.
|
||||
* @returns {FixupRuleDefinition} The fixed-up rule.
|
||||
*/
|
||||
export function fixupRule(ruleDefinition: FixupRuleDefinition | FixupLegacyRuleDefinition): FixupRuleDefinition;
|
||||
/**
|
||||
* Reads an ignore file and returns an object with the ignore patterns.
|
||||
* @param {string} ignoreFilePath The absolute path to the ignore file.
|
||||
* @returns {FlatConfig} An object with an `ignores` property that is an array of ignore patterns.
|
||||
* @throws {Error} If the ignore file path is not an absolute path.
|
||||
*/
|
||||
export function includeIgnoreFile(ignoreFilePath: string): FlatConfig;
|
||||
45
github/codeql-action-v2/node_modules/@eslint/compat/dist/esm/index.d.ts
generated
vendored
Normal file
45
github/codeql-action-v2/node_modules/@eslint/compat/dist/esm/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
export type FlatConfig = import("eslint").Linter.FlatConfig;
|
||||
export type FixupPluginDefinition = import("eslint").ESLint.Plugin;
|
||||
export type FixupRuleDefinition = import("eslint").Rule.RuleModule;
|
||||
export type FixupLegacyRuleDefinition = import("eslint").Rule.OldStyleRule;
|
||||
export type FixupConfig = import("eslint").Linter.FlatConfig;
|
||||
export type FixupConfigArray = Array<FixupConfig>;
|
||||
/**
|
||||
* @fileoverview Ignore file utilities for the compat package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
/** @typedef {import("eslint").Linter.FlatConfig} FlatConfig */
|
||||
/**
|
||||
* Converts an ESLint ignore pattern to a minimatch pattern.
|
||||
* @param {string} pattern The .eslintignore or .gitignore pattern to convert.
|
||||
* @returns {string} The converted pattern.
|
||||
*/
|
||||
export function convertIgnorePatternToMinimatch(pattern: string): string;
|
||||
/**
|
||||
* Takes the given configuration and creates a new configuration with all of the
|
||||
* rules wrapped to provide the missing methods on the `context` object.
|
||||
* @param {FixupConfigArray|FixupConfig} config The configuration to fix up.
|
||||
* @returns {FixupConfigArray} The fixed-up configuration.
|
||||
*/
|
||||
export function fixupConfigRules(config: FixupConfigArray | FixupConfig): FixupConfigArray;
|
||||
/**
|
||||
* Takes the given plugin and creates a new plugin with all of the rules wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupPluginDefinition} plugin The plugin to fix up.
|
||||
* @returns {FixupPluginDefinition} The fixed-up plugin.
|
||||
*/
|
||||
export function fixupPluginRules(plugin: FixupPluginDefinition): FixupPluginDefinition;
|
||||
/**
|
||||
* Takes the given rule and creates a new rule with the `create()` method wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupRuleDefinition|FixupLegacyRuleDefinition} ruleDefinition The rule to fix up.
|
||||
* @returns {FixupRuleDefinition} The fixed-up rule.
|
||||
*/
|
||||
export function fixupRule(ruleDefinition: FixupRuleDefinition | FixupLegacyRuleDefinition): FixupRuleDefinition;
|
||||
/**
|
||||
* Reads an ignore file and returns an object with the ignore patterns.
|
||||
* @param {string} ignoreFilePath The absolute path to the ignore file.
|
||||
* @returns {FlatConfig} An object with an `ignores` property that is an array of ignore patterns.
|
||||
* @throws {Error} If the ignore file path is not an absolute path.
|
||||
*/
|
||||
export function includeIgnoreFile(ignoreFilePath: string): FlatConfig;
|
||||
346
github/codeql-action-v2/node_modules/@eslint/compat/dist/esm/index.js
generated
vendored
Normal file
346
github/codeql-action-v2/node_modules/@eslint/compat/dist/esm/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
// @ts-self-types="./index.d.ts"
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
/**
|
||||
* @filedescription Functions to fix up rules to provide missing methods on the `context` object.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint").ESLint.Plugin} FixupPluginDefinition */
|
||||
/** @typedef {import("eslint").Rule.RuleModule} FixupRuleDefinition */
|
||||
/** @typedef {import("eslint").Rule.OldStyleRule} FixupLegacyRuleDefinition */
|
||||
/** @typedef {import("eslint").Linter.FlatConfig} FixupConfig */
|
||||
/** @typedef {Array<FixupConfig>} FixupConfigArray */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The removed methods from the `context` object that need to be added back.
|
||||
* The keys are the name of the method on the `context` object and the values
|
||||
* are the name of the method on the `sourceCode` object.
|
||||
* @type {Map<string, string>}
|
||||
*/
|
||||
const removedMethodNames = new Map([
|
||||
["getSource", "getText"],
|
||||
["getSourceLines", "getLines"],
|
||||
["getAllComments", "getAllComments"],
|
||||
["getDeclaredVariables", "getDeclaredVariables"],
|
||||
["getNodeByRangeIndex", "getNodeByRangeIndex"],
|
||||
["getCommentsBefore", "getCommentsBefore"],
|
||||
["getCommentsAfter", "getCommentsAfter"],
|
||||
["getCommentsInside", "getCommentsInside"],
|
||||
["getJSDocComment", "getJSDocComment"],
|
||||
["getFirstToken", "getFirstToken"],
|
||||
["getFirstTokens", "getFirstTokens"],
|
||||
["getLastToken", "getLastToken"],
|
||||
["getLastTokens", "getLastTokens"],
|
||||
["getTokenAfter", "getTokenAfter"],
|
||||
["getTokenBefore", "getTokenBefore"],
|
||||
["getTokenByRangeStart", "getTokenByRangeStart"],
|
||||
["getTokens", "getTokens"],
|
||||
["getTokensAfter", "getTokensAfter"],
|
||||
["getTokensBefore", "getTokensBefore"],
|
||||
["getTokensBetween", "getTokensBetween"],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Tracks the original rule definition and the fixed-up rule definition.
|
||||
* @type {WeakMap<FixupRuleDefinition|FixupLegacyRuleDefinition,FixupRuleDefinition>}
|
||||
*/
|
||||
const fixedUpRuleReplacements = new WeakMap();
|
||||
|
||||
/**
|
||||
* Tracks all of the fixed up rule definitions so we don't duplicate effort.
|
||||
* @type {WeakSet<FixupRuleDefinition>}
|
||||
*/
|
||||
const fixedUpRules = new WeakSet();
|
||||
|
||||
/**
|
||||
* Tracks the original plugin definition and the fixed-up plugin definition.
|
||||
* @type {WeakMap<FixupPluginDefinition,FixupPluginDefinition>}
|
||||
*/
|
||||
const fixedUpPluginReplacements = new WeakMap();
|
||||
|
||||
/**
|
||||
* Tracks all of the fixed up plugin definitions so we don't duplicate effort.
|
||||
* @type {WeakSet<FixupPluginDefinition>}
|
||||
*/
|
||||
const fixedUpPlugins = new WeakSet();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Takes the given rule and creates a new rule with the `create()` method wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupRuleDefinition|FixupLegacyRuleDefinition} ruleDefinition The rule to fix up.
|
||||
* @returns {FixupRuleDefinition} The fixed-up rule.
|
||||
*/
|
||||
function fixupRule(ruleDefinition) {
|
||||
// first check if we've already fixed up this rule
|
||||
if (fixedUpRuleReplacements.has(ruleDefinition)) {
|
||||
return fixedUpRuleReplacements.get(ruleDefinition);
|
||||
}
|
||||
|
||||
const isLegacyRule = typeof ruleDefinition === "function";
|
||||
|
||||
// check to see if this rule definition has already been fixed up
|
||||
if (!isLegacyRule && fixedUpRules.has(ruleDefinition)) {
|
||||
return ruleDefinition;
|
||||
}
|
||||
|
||||
const originalCreate = isLegacyRule
|
||||
? ruleDefinition
|
||||
: ruleDefinition.create.bind(ruleDefinition);
|
||||
|
||||
function ruleCreate(context) {
|
||||
// if getScope is already there then no need to create old methods
|
||||
if ("getScope" in context) {
|
||||
return originalCreate(context);
|
||||
}
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
let currentNode = sourceCode.ast;
|
||||
|
||||
const newContext = Object.assign(Object.create(context), {
|
||||
parserServices: sourceCode.parserServices,
|
||||
|
||||
/*
|
||||
* The following methods rely on the current node in the traversal,
|
||||
* so we need to add them manually.
|
||||
*/
|
||||
getScope() {
|
||||
return sourceCode.getScope(currentNode);
|
||||
},
|
||||
|
||||
getAncestors() {
|
||||
return sourceCode.getAncestors(currentNode);
|
||||
},
|
||||
|
||||
markVariableAsUsed(variable) {
|
||||
sourceCode.markVariableAsUsed(variable, currentNode);
|
||||
},
|
||||
});
|
||||
|
||||
// add passthrough methods
|
||||
for (const [
|
||||
contextMethodName,
|
||||
sourceCodeMethodName,
|
||||
] of removedMethodNames) {
|
||||
newContext[contextMethodName] =
|
||||
sourceCode[sourceCodeMethodName].bind(sourceCode);
|
||||
}
|
||||
|
||||
// freeze just like the original context
|
||||
Object.freeze(newContext);
|
||||
|
||||
/*
|
||||
* Create the visitor object using the original create() method.
|
||||
* This is necessary to ensure that the visitor object is created
|
||||
* with the correct context.
|
||||
*/
|
||||
const visitor = originalCreate(newContext);
|
||||
|
||||
/*
|
||||
* Wrap each method in the visitor object to update the currentNode
|
||||
* before calling the original method. This is necessary because the
|
||||
* methods like `getScope()` need to know the current node.
|
||||
*/
|
||||
for (const [methodName, method] of Object.entries(visitor)) {
|
||||
/*
|
||||
* Node is the second argument to most code path methods,
|
||||
* and the third argument for onCodePathSegmentLoop.
|
||||
*/
|
||||
if (methodName.startsWith("on")) {
|
||||
// eslint-disable-next-line no-loop-func -- intentionally updating shared `currentNode` variable
|
||||
visitor[methodName] = (...args) => {
|
||||
currentNode =
|
||||
args[methodName === "onCodePathSegmentLoop" ? 2 : 1];
|
||||
|
||||
return method.call(visitor, ...args);
|
||||
};
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-loop-func -- intentionally updating shared `currentNode` variable
|
||||
visitor[methodName] = (...args) => {
|
||||
currentNode = args[0];
|
||||
|
||||
return method.call(visitor, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
return visitor;
|
||||
}
|
||||
|
||||
const newRuleDefinition = {
|
||||
...(isLegacyRule ? undefined : ruleDefinition),
|
||||
create: ruleCreate,
|
||||
};
|
||||
|
||||
// cache the fixed up rule
|
||||
fixedUpRuleReplacements.set(ruleDefinition, newRuleDefinition);
|
||||
fixedUpRules.add(newRuleDefinition);
|
||||
|
||||
return newRuleDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the given plugin and creates a new plugin with all of the rules wrapped
|
||||
* to provide the missing methods on the `context` object.
|
||||
* @param {FixupPluginDefinition} plugin The plugin to fix up.
|
||||
* @returns {FixupPluginDefinition} The fixed-up plugin.
|
||||
*/
|
||||
function fixupPluginRules(plugin) {
|
||||
// first check if we've already fixed up this plugin
|
||||
if (fixedUpPluginReplacements.has(plugin)) {
|
||||
return fixedUpPluginReplacements.get(plugin);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the plugin has already been fixed up, or if the plugin
|
||||
* doesn't have any rules, we can just return it.
|
||||
*/
|
||||
if (fixedUpPlugins.has(plugin) || !plugin.rules) {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
const newPlugin = {
|
||||
...plugin,
|
||||
rules: Object.fromEntries(
|
||||
Object.entries(plugin.rules).map(([ruleId, ruleDefinition]) => [
|
||||
ruleId,
|
||||
fixupRule(ruleDefinition),
|
||||
]),
|
||||
),
|
||||
};
|
||||
|
||||
// cache the fixed up plugin
|
||||
fixedUpPluginReplacements.set(plugin, newPlugin);
|
||||
fixedUpPlugins.add(newPlugin);
|
||||
|
||||
return newPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the given configuration and creates a new configuration with all of the
|
||||
* rules wrapped to provide the missing methods on the `context` object.
|
||||
* @param {FixupConfigArray|FixupConfig} config The configuration to fix up.
|
||||
* @returns {FixupConfigArray} The fixed-up configuration.
|
||||
*/
|
||||
function fixupConfigRules(config) {
|
||||
const configs = Array.isArray(config) ? config : [config];
|
||||
|
||||
return configs.map(configItem => {
|
||||
if (!configItem.plugins) {
|
||||
return configItem;
|
||||
}
|
||||
|
||||
const newPlugins = Object.fromEntries(
|
||||
Object.entries(configItem.plugins).map(([pluginName, plugin]) => [
|
||||
pluginName,
|
||||
fixupPluginRules(plugin),
|
||||
]),
|
||||
);
|
||||
|
||||
return {
|
||||
...configItem,
|
||||
plugins: newPlugins,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Ignore file utilities for the compat package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint").Linter.FlatConfig} FlatConfig */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Converts an ESLint ignore pattern to a minimatch pattern.
|
||||
* @param {string} pattern The .eslintignore or .gitignore pattern to convert.
|
||||
* @returns {string} The converted pattern.
|
||||
*/
|
||||
function convertIgnorePatternToMinimatch(pattern) {
|
||||
const isNegated = pattern.startsWith("!");
|
||||
const negatedPrefix = isNegated ? "!" : "";
|
||||
const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd();
|
||||
|
||||
// special cases
|
||||
if (["", "**", "/**", "**/"].includes(patternToTest)) {
|
||||
return `${negatedPrefix}${patternToTest}`;
|
||||
}
|
||||
|
||||
const firstIndexOfSlash = patternToTest.indexOf("/");
|
||||
|
||||
const matchEverywherePrefix =
|
||||
firstIndexOfSlash < 0 || firstIndexOfSlash === patternToTest.length - 1
|
||||
? "**/"
|
||||
: "";
|
||||
|
||||
const patternWithoutLeadingSlash =
|
||||
firstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest;
|
||||
|
||||
/*
|
||||
* Escape `{` and `(` because in gitignore patterns they are just
|
||||
* literal characters without any specific syntactic meaning,
|
||||
* while in minimatch patterns they can form brace expansion or extglob syntax.
|
||||
*
|
||||
* For example, gitignore pattern `src/{a,b}.js` ignores file `src/{a,b}.js`.
|
||||
* But, the same minimatch pattern `src/{a,b}.js` ignores files `src/a.js` and `src/b.js`.
|
||||
* Minimatch pattern `src/\{a,b}.js` is equivalent to gitignore pattern `src/{a,b}.js`.
|
||||
*/
|
||||
const escapedPatternWithoutLeadingSlash =
|
||||
patternWithoutLeadingSlash.replaceAll(
|
||||
/(?=((?:\\.|[^{(])*))\1([{(])/guy,
|
||||
"$1\\$2",
|
||||
);
|
||||
|
||||
const matchInsideSuffix = patternToTest.endsWith("/**") ? "/*" : "";
|
||||
|
||||
return `${negatedPrefix}${matchEverywherePrefix}${escapedPatternWithoutLeadingSlash}${matchInsideSuffix}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an ignore file and returns an object with the ignore patterns.
|
||||
* @param {string} ignoreFilePath The absolute path to the ignore file.
|
||||
* @returns {FlatConfig} An object with an `ignores` property that is an array of ignore patterns.
|
||||
* @throws {Error} If the ignore file path is not an absolute path.
|
||||
*/
|
||||
function includeIgnoreFile(ignoreFilePath) {
|
||||
if (!path.isAbsolute(ignoreFilePath)) {
|
||||
throw new Error("The ignore file location must be an absolute path.");
|
||||
}
|
||||
|
||||
const ignoreFile = fs.readFileSync(ignoreFilePath, "utf8");
|
||||
const lines = ignoreFile.split(/\r?\n/u);
|
||||
|
||||
return {
|
||||
name: "Imported .gitignore patterns",
|
||||
ignores: lines
|
||||
.map(line => line.trim())
|
||||
.filter(line => line && !line.startsWith("#"))
|
||||
.map(convertIgnorePatternToMinimatch),
|
||||
};
|
||||
}
|
||||
|
||||
export { convertIgnorePatternToMinimatch, fixupConfigRules, fixupPluginRules, fixupRule, includeIgnoreFile };
|
||||
61
github/codeql-action-v2/node_modules/@eslint/compat/package.json
generated
vendored
Normal file
61
github/codeql-action-v2/node_modules/@eslint/compat/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "@eslint/compat",
|
||||
"version": "1.1.1",
|
||||
"description": "Compatibility utilities for ESLint",
|
||||
"type": "module",
|
||||
"main": "dist/esm/index.js",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\"",
|
||||
"build": "rollup -c && tsc -p tsconfig.esm.json && npm run build:cts",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"test": "mocha tests/*.js",
|
||||
"test:coverage": "c8 npm test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint/rewrite.git"
|
||||
},
|
||||
"keywords": [
|
||||
"eslint",
|
||||
"compatibility",
|
||||
"eslintplugin",
|
||||
"eslint-plugin"
|
||||
],
|
||||
"author": "Nicholas C. Zakas",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite#readme",
|
||||
"devDependencies": {
|
||||
"@types/eslint": "^8.56.10",
|
||||
"c8": "^9.1.0",
|
||||
"eslint": "^9.0.0",
|
||||
"mocha": "^10.4.0",
|
||||
"rollup": "^4.16.2",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue