mirror of
https://github.com/github/codeql-action.git
synced 2025-12-25 08:40:12 +08:00
Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afb54ba388 | ||
|
|
57a4b22c7d | ||
|
|
4b1d7da102 | ||
|
|
97e8f69368 | ||
|
|
f8e94f9775 | ||
|
|
9e375a8f4f | ||
|
|
02d73d0544 | ||
|
|
5cf07d8b70 | ||
|
|
ecab108bfb | ||
|
|
1b214db077 | ||
|
|
826b78c018 | ||
|
|
f67c9cd326 | ||
|
|
77e41720af | ||
|
|
4733419117 | ||
|
|
6186179441 | ||
|
|
7b43b7c7ca | ||
|
|
5669f66a72 | ||
|
|
b400d0f668 | ||
|
|
736528d92f | ||
|
|
98042e78ca | ||
|
|
892ff9ec25 | ||
|
|
edfef2739a | ||
|
|
7ad1090882 | ||
|
|
7cb4b5a421 | ||
|
|
0e346f2c4a | ||
|
|
4e038ccdaf | ||
|
|
59c6d06ad6 | ||
|
|
ea8137f35f | ||
|
|
b516521723 | ||
|
|
44534b787f | ||
|
|
667992c63e | ||
|
|
000ba111dd | ||
|
|
2d790406f5 | ||
|
|
232a8bc80e | ||
|
|
270a29d1cc | ||
|
|
58f46da2c3 | ||
|
|
f2166816d7 | ||
|
|
8e147925e0 | ||
|
|
e6663d9fa2 | ||
|
|
455bd98666 | ||
|
|
778c2bc28d | ||
|
|
3cf7236447 | ||
|
|
c2585eca08 | ||
|
|
d2d99b1ac4 | ||
|
|
09653b7034 | ||
|
|
e6438b3296 | ||
|
|
857f661639 | ||
|
|
98995113ab | ||
|
|
a9885c76a1 | ||
|
|
4fa2a79536 | ||
|
|
dec6fb713c | ||
|
|
947b18fb72 | ||
|
|
9ab727712f | ||
|
|
1c60bf167b | ||
|
|
b85b404fb1 | ||
|
|
a4f3debdaa | ||
|
|
e1f83c153a | ||
|
|
be825d5eef | ||
|
|
243e392ed0 | ||
|
|
026682fb73 | ||
|
|
264cbe20c6 | ||
|
|
0b65015a1d | ||
|
|
f48d8801fa | ||
|
|
6e04d518ba | ||
|
|
6478fc9b50 | ||
|
|
0a4755e088 | ||
|
|
0669d181f5 | ||
|
|
a98055bc5b | ||
|
|
a0041ad76c | ||
|
|
064a406de0 | ||
|
|
2d3d0ca0c7 | ||
|
|
7adf9ac915 | ||
|
|
01bde733fb | ||
|
|
8dba596f10 | ||
|
|
7e6aa4d65a | ||
|
|
44f8d40662 | ||
|
|
4b9726b71f | ||
|
|
ee4ad8b9d6 | ||
|
|
249d690124 | ||
|
|
bfdafbcc1e | ||
|
|
9679491cab | ||
|
|
6c2a71ced3 | ||
|
|
ddd849e831 | ||
|
|
dbfc2b6359 | ||
|
|
0ff1bdba7f | ||
|
|
79e9a50e51 | ||
|
|
80ab1ac076 | ||
|
|
7bb9277650 | ||
|
|
37b6ead477 | ||
|
|
bef80a1974 | ||
|
|
8a9ecdff2e | ||
|
|
a52b209ec8 |
@@ -1,71 +0,0 @@
|
||||
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"plugins": ["@typescript-eslint", "filenames", "github", "import", "no-async-foreach"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
"plugin:github/recommended",
|
||||
"plugin:github/typescript",
|
||||
"plugin:import/typescript"
|
||||
],
|
||||
"rules": {
|
||||
"filenames/match-regex": ["error", "^[a-z0-9-]+(\\.test)?$"],
|
||||
"i18n-text/no-en": "off",
|
||||
"import/extensions": ["error", {
|
||||
// Allow importing JSON files
|
||||
"json": {}
|
||||
}],
|
||||
"import/no-amd": "error",
|
||||
"import/no-commonjs": "error",
|
||||
"import/no-cycle": "error",
|
||||
"import/no-dynamic-require": "error",
|
||||
// Disable the rule that checks that devDependencies aren't imported since we use a single
|
||||
// linting configuration file for both source and test code.
|
||||
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
|
||||
"import/no-namespace": "off",
|
||||
"import/no-unresolved": "error",
|
||||
"import/no-webpack-loader-syntax": "error",
|
||||
"import/order": ["error", {
|
||||
"alphabetize": {"order": "asc"},
|
||||
"newlines-between": "always"
|
||||
}],
|
||||
"max-len": ["error", {
|
||||
"code": 120,
|
||||
"ignoreUrls": true,
|
||||
"ignoreStrings": true,
|
||||
"ignoreTemplateLiterals": true
|
||||
}],
|
||||
"no-async-foreach/no-async-foreach": "error",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": "off",
|
||||
"@typescript-eslint/no-shadow": "error",
|
||||
"one-var": ["error", "never"]
|
||||
},
|
||||
"overrides": [{
|
||||
// "temporarily downgraded during transition to eslint
|
||||
"files": "**",
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/prefer-regexp-exec": "off",
|
||||
"@typescript-eslint/require-await": "off",
|
||||
"@typescript-eslint/restrict-template-expressions": "off",
|
||||
"func-style": "off"
|
||||
}
|
||||
}],
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"node": {
|
||||
"moduleDirectory": ["node_modules", "src"]
|
||||
},
|
||||
"typescript": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
.github/actions/check-sarif/action.yml
vendored
2
.github/actions/check-sarif/action.yml
vendored
@@ -16,5 +16,5 @@ inputs:
|
||||
Comma separated list of query ids that should NOT be included in this SARIF file.
|
||||
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: index.js
|
||||
|
||||
3
.github/workflows/pr-checks.yml
vendored
3
.github/workflows/pr-checks.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-types-version: [16.11, current] # we backport this matrix job in order to maintain the same check names
|
||||
node-types-version: [16.11, current] # run tests on 16.11 while CodeQL Action v2 is still supported
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -50,7 +50,6 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Check generated JS
|
||||
if: matrix.node-types-version != 'current' # we do not need to test the newer node on the v2 branch
|
||||
run: .github/workflows/script/check-js.sh
|
||||
|
||||
check-node-modules:
|
||||
|
||||
81
CHANGELOG.md
81
CHANGELOG.md
@@ -4,137 +4,160 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
|
||||
|
||||
Note that the only difference between `v2` and `v3` of the CodeQL Action is the node version they support, with `v3` running on node 20 while we continue to release `v2` to support running on node 16. For example `3.22.11` was the first `v3` release and is functionally identical to `2.22.11`. This approach ensures an easy way to track exactly which features are included in different versions, indicated by the minor and patch version numbers.
|
||||
|
||||
## 2.25.11 - 28 Jun 2024
|
||||
## 3.25.15 - 26 Jul 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.18.1. [#2385](https://github.com/github/codeql-action/pull/2385)
|
||||
|
||||
## 3.25.14 - 25 Jul 2024
|
||||
|
||||
- Experimental: add a new `start-proxy` action which starts the same HTTP proxy as used by [`github/dependabot-action`](https://github.com/github/dependabot-action). Do not use this in production as it is part of an internal experiment and subject to change at any time.
|
||||
|
||||
## 3.25.13 - 19 Jul 2024
|
||||
|
||||
- Add `codeql-version` to outputs. [#2368](https://github.com/github/codeql-action/pull/2368)
|
||||
- Add a deprecation warning for customers using CodeQL version 2.13.4 and earlier. These versions of CodeQL were discontinued on 9 July 2024 alongside GitHub Enterprise Server 3.9, and will be unsupported by CodeQL Action versions 3.26.0 and later and versions 2.26.0 and later. [#2375](https://github.com/github/codeql-action/pull/2375)
|
||||
- If you are using one of these versions, please update to CodeQL CLI version 2.13.5 or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version.
|
||||
- Alternatively, if you want to continue using a version of the CodeQL CLI between 2.12.6 and 2.13.4, you can replace `github/codeql-action/*@v3` by `github/codeql-action/*@v3.25.13` and `github/codeql-action/*@v2` by `github/codeql-action/*@v2.25.13` in your code scanning workflow to ensure you continue using this version of the CodeQL Action.
|
||||
|
||||
## 3.25.12 - 12 Jul 2024
|
||||
|
||||
- Improve the reliability and performance of analyzing code when analyzing a compiled language with the `autobuild` [build mode](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#codeql-build-modes) on GitHub Enterprise Server. This feature is already available to GitHub.com users. [#2353](https://github.com/github/codeql-action/pull/2353)
|
||||
- Update default CodeQL bundle version to 2.18.0. [#2364](https://github.com/github/codeql-action/pull/2364)
|
||||
|
||||
## 3.25.11 - 28 Jun 2024
|
||||
|
||||
- Avoid failing the workflow run if there is an error while uploading debug artifacts. [#2349](https://github.com/github/codeql-action/pull/2349)
|
||||
- Update default CodeQL bundle version to 2.17.6. [#2352](https://github.com/github/codeql-action/pull/2352)
|
||||
|
||||
## 2.25.10 - 13 Jun 2024
|
||||
## 3.25.10 - 13 Jun 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.17.5. [#2327](https://github.com/github/codeql-action/pull/2327)
|
||||
|
||||
## 2.25.9 - 12 Jun 2024
|
||||
## 3.25.9 - 12 Jun 2024
|
||||
|
||||
- Avoid failing database creation if the database folder already exists and contains some unexpected files. Requires CodeQL 2.18.0 or higher. [#2330](https://github.com/github/codeql-action/pull/2330)
|
||||
- The init Action will attempt to clean up the database cluster directory before creating a new database and at the end of the job. This will help to avoid issues where the database cluster directory is left in an inconsistent state. [#2332](https://github.com/github/codeql-action/pull/2332)
|
||||
|
||||
## 2.25.8 - 04 Jun 2024
|
||||
## 3.25.8 - 04 Jun 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.17.4. [#2321](https://github.com/github/codeql-action/pull/2321)
|
||||
|
||||
## 2.25.7 - 31 May 2024
|
||||
## 3.25.7 - 31 May 2024
|
||||
|
||||
- We are rolling out a feature in May/June 2024 that will reduce the Actions cache usage of the Action by keeping only the newest TRAP cache for each language. [#2306](https://github.com/github/codeql-action/pull/2306)
|
||||
|
||||
## 2.25.6 - 20 May 2024
|
||||
## 3.25.6 - 20 May 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.17.3. [#2295](https://github.com/github/codeql-action/pull/2295)
|
||||
|
||||
## 2.25.5 - 13 May 2024
|
||||
## 3.25.5 - 13 May 2024
|
||||
|
||||
- Add a compatibility matrix of supported CodeQL Action, CodeQL CLI, and GitHub Enterprise Server versions to the [README.md](README.md). [#2273](https://github.com/github/codeql-action/pull/2273)
|
||||
- Avoid printing out a warning for a missing `on.push` trigger when the CodeQL Action is triggered via a `workflow_call` event. [#2274](https://github.com/github/codeql-action/pull/2274)
|
||||
- The `tools: latest` input to the `init` Action has been renamed to `tools: linked`. This option specifies that the Action should use the tools shipped at the same time as the Action. The old name will continue to work for backwards compatibility, but we recommend that new workflows use the new name. [#2281](https://github.com/github/codeql-action/pull/2281)
|
||||
|
||||
## 2.25.4 - 08 May 2024
|
||||
## 3.25.4 - 08 May 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.17.2. [#2270](https://github.com/github/codeql-action/pull/2270)
|
||||
|
||||
## 2.25.3 - 25 Apr 2024
|
||||
## 3.25.3 - 25 Apr 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.17.1. [#2247](https://github.com/github/codeql-action/pull/2247)
|
||||
- Workflows running on `macos-latest` using CodeQL CLI versions before v2.15.1 will need to either upgrade their CLI version to v2.15.1 or newer, or change the platform to an Intel MacOS runner, such as `macos-12`. ARM machines with SIP disabled, including the newest `macos-latest` image, are unsupported for CLI versions before 2.15.1. [#2261](https://github.com/github/codeql-action/pull/2261)
|
||||
|
||||
## 2.25.2 - 22 Apr 2024
|
||||
## 3.25.2 - 22 Apr 2024
|
||||
|
||||
No user facing changes.
|
||||
|
||||
## 2.25.1 - 17 Apr 2024
|
||||
## 3.25.1 - 17 Apr 2024
|
||||
|
||||
- We are rolling out a feature in April/May 2024 that improves the reliability and performance of analyzing code when analyzing a compiled language with the `autobuild` [build mode](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#codeql-build-modes). [#2235](https://github.com/github/codeql-action/pull/2235)
|
||||
- Fix a bug where the `init` Action would fail if `--overwrite` was specified in `CODEQL_ACTION_EXTRA_OPTIONS`. [#2245](https://github.com/github/codeql-action/pull/2245)
|
||||
|
||||
## 2.25.0 - 15 Apr 2024
|
||||
## 3.25.0 - 15 Apr 2024
|
||||
|
||||
- The deprecated feature for extracting dependencies for a Python analysis has been removed. [#2224](https://github.com/github/codeql-action/pull/2224)
|
||||
|
||||
As a result, the following inputs and environment variables are now ignored:
|
||||
|
||||
- The `setup-python-dependencies` input to the `init` Action
|
||||
- The `CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION` environment variable
|
||||
|
||||
We recommend removing any references to these from your workflows. For more information, see the release notes for CodeQL Action v3.23.0 and v2.23.0.
|
||||
- Automatically overwrite an existing database if found on the filesystem. [#2229](https://github.com/github/codeql-action/pull/2229)
|
||||
- Bump the minimum CodeQL bundle version to 2.12.6. [#2232](https://github.com/github/codeql-action/pull/2232)
|
||||
- A more relevant log message and a diagnostic are now emitted when the `file` program is not installed on a Linux runner, but is required for Go tracing to succeed. [#2234](https://github.com/github/codeql-action/pull/2234)
|
||||
|
||||
## 2.24.10 - 05 Apr 2024
|
||||
## 3.24.10 - 05 Apr 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.17.0. [#2219](https://github.com/github/codeql-action/pull/2219)
|
||||
- Add a deprecation warning for customers using CodeQL version 2.12.5 and earlier. These versions of CodeQL were discontinued on 26 March 2024 alongside GitHub Enterprise Server 3.8, and will be unsupported by CodeQL Action versions 3.25.0 and later and versions 2.25.0 and later. [#2220](https://github.com/github/codeql-action/pull/2220)
|
||||
- If you are using one of these versions, please update to CodeQL CLI version 2.12.6 or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version.
|
||||
- Alternatively, if you want to continue using a version of the CodeQL CLI between 2.11.6 and 2.12.5, you can replace `github/codeql-action/*@v3` by `github/codeql-action/*@v3.24.10` and `github/codeql-action/*@v2` by `github/codeql-action/*@v2.24.10` in your code scanning workflow to ensure you continue using this version of the CodeQL Action.
|
||||
|
||||
## 2.24.9 - 22 Mar 2024
|
||||
## 3.24.9 - 22 Mar 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.16.5. [#2203](https://github.com/github/codeql-action/pull/2203)
|
||||
|
||||
## 2.24.8 - 18 Mar 2024
|
||||
## 3.24.8 - 18 Mar 2024
|
||||
|
||||
- Improve the ease of debugging extraction issues by increasing the verbosity of the extractor logs when running in debug mode. [#2195](https://github.com/github/codeql-action/pull/2195)
|
||||
|
||||
## 2.24.7 - 12 Mar 2024
|
||||
## 3.24.7 - 12 Mar 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.16.4. [#2185](https://github.com/github/codeql-action/pull/2185)
|
||||
|
||||
## 2.24.6 - 29 Feb 2024
|
||||
## 3.24.6 - 29 Feb 2024
|
||||
|
||||
No user facing changes.
|
||||
|
||||
## 2.24.5 - 23 Feb 2024
|
||||
## 3.24.5 - 23 Feb 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.16.3. [#2156](https://github.com/github/codeql-action/pull/2156)
|
||||
|
||||
## 2.24.4 - 21 Feb 2024
|
||||
## 3.24.4 - 21 Feb 2024
|
||||
|
||||
- Fix an issue where an existing, but empty, `/sys/fs/cgroup/cpuset.cpus` file always resulted in a single-threaded run. [#2151](https://github.com/github/codeql-action/pull/2151)
|
||||
|
||||
## 2.24.3 - 15 Feb 2024
|
||||
## 3.24.3 - 15 Feb 2024
|
||||
|
||||
- Fix an issue where the CodeQL Action would fail to load a configuration specified by the `config` input to the `init` Action. [#2147](https://github.com/github/codeql-action/pull/2147)
|
||||
|
||||
## 2.24.2 - 15 Feb 2024
|
||||
## 3.24.2 - 15 Feb 2024
|
||||
|
||||
- Enable improved multi-threaded performance on larger runners for GitHub Enterprise Server users. This feature is already available to GitHub.com users. [#2141](https://github.com/github/codeql-action/pull/2141)
|
||||
|
||||
## 2.24.1 - 13 Feb 2024
|
||||
## 3.24.1 - 13 Feb 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.16.2. [#2124](https://github.com/github/codeql-action/pull/2124)
|
||||
- The CodeQL action no longer fails if it can't write to the telemetry api endpoint. [#2121](https://github.com/github/codeql-action/pull/2121)
|
||||
|
||||
## 2.24.0 - 02 Feb 2024
|
||||
## 3.24.0 - 02 Feb 2024
|
||||
|
||||
- CodeQL Python analysis will no longer install dependencies on GitHub Enterprise Server, as is already the case for GitHub.com. See [release notes for 3.23.0](#3230---08-jan-2024) for more details. [#2106](https://github.com/github/codeql-action/pull/2106)
|
||||
|
||||
## 2.23.2 - 26 Jan 2024
|
||||
## 3.23.2 - 26 Jan 2024
|
||||
|
||||
- On Linux, the maximum possible value for the `--threads` option now respects the CPU count as specified in `cgroup` files to more accurately reflect the number of available cores when running in containers. [#2083](https://github.com/github/codeql-action/pull/2083)
|
||||
- Update default CodeQL bundle version to 2.16.1. [#2096](https://github.com/github/codeql-action/pull/2096)
|
||||
|
||||
## 2.23.1 - 17 Jan 2024
|
||||
## 3.23.1 - 17 Jan 2024
|
||||
|
||||
- Update default CodeQL bundle version to 2.16.0. [#2073](https://github.com/github/codeql-action/pull/2073)
|
||||
- Change the retention period for uploaded debug artifacts to 7 days. Previously, this was whatever the repository default was. [#2079](https://github.com/github/codeql-action/pull/2079)
|
||||
|
||||
## 2.23.0 - 08 Jan 2024
|
||||
## 3.23.0 - 08 Jan 2024
|
||||
|
||||
- We are rolling out a feature in January 2024 that will disable Python dependency installation by default for all users. This improves the speed of analysis while having only a very minor impact on results. You can override this behavior by setting `CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION=false` in your workflow, however we plan to remove this ability in future versions of the CodeQL Action. [#2031](https://github.com/github/codeql-action/pull/2031)
|
||||
- The CodeQL Action now requires CodeQL version 2.11.6 or later. For more information, see [the corresponding changelog entry for CodeQL Action version 2.22.7](#2227---16-nov-2023). [#2009](https://github.com/github/codeql-action/pull/2009)
|
||||
|
||||
## 2.22.12 - 22 Dec 2023
|
||||
## 3.22.12 - 22 Dec 2023
|
||||
|
||||
- Update default CodeQL bundle version to 2.15.5. [#2047](https://github.com/github/codeql-action/pull/2047)
|
||||
|
||||
## 2.22.11 - 13 Dec 2023
|
||||
## 3.22.11 - 13 Dec 2023
|
||||
|
||||
No user facing changes.
|
||||
- [v3+ only] The CodeQL Action now runs on Node.js v20. [#2006](https://github.com/github/codeql-action/pull/2006)
|
||||
|
||||
## 2.22.10 - 12 Dec 2023
|
||||
|
||||
|
||||
@@ -86,6 +86,6 @@ outputs:
|
||||
sarif-id:
|
||||
description: The ID of the uploaded SARIF file.
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: "../lib/analyze-action.js"
|
||||
post: "../lib/analyze-action-post.js"
|
||||
|
||||
@@ -15,5 +15,5 @@ inputs:
|
||||
$GITHUB_WORKSPACE as its working directory.
|
||||
required: false
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: '../lib/autobuild-action.js'
|
||||
|
||||
149
eslint.config.mjs
Normal file
149
eslint.config.mjs
Normal file
@@ -0,0 +1,149 @@
|
||||
// Automatically generated by running npx @eslint/migrate-config .eslintrc.json
|
||||
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
|
||||
import { FlatCompat } from "@eslint/eslintrc";
|
||||
import js from "@eslint/js";
|
||||
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
||||
import tsParser from "@typescript-eslint/parser";
|
||||
import filenames from "eslint-plugin-filenames";
|
||||
import github from "eslint-plugin-github";
|
||||
import _import from "eslint-plugin-import";
|
||||
import noAsyncForeach from "eslint-plugin-no-async-foreach";
|
||||
import globals from "globals";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname,
|
||||
recommendedConfig: js.configs.recommended,
|
||||
allConfig: js.configs.all,
|
||||
});
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: [
|
||||
"**/webpack.config.js",
|
||||
"lib/**/*",
|
||||
"src/testdata/**/*",
|
||||
"tests/**/*",
|
||||
"eslint.config.mjs",
|
||||
".github/**/*",
|
||||
],
|
||||
},
|
||||
...fixupConfigRules(
|
||||
compat.extends(
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
"plugin:github/recommended",
|
||||
"plugin:github/typescript",
|
||||
"plugin:import/typescript",
|
||||
),
|
||||
),
|
||||
{
|
||||
plugins: {
|
||||
"@typescript-eslint": fixupPluginRules(typescriptEslint),
|
||||
filenames: fixupPluginRules(filenames),
|
||||
github: fixupPluginRules(github),
|
||||
import: fixupPluginRules(_import),
|
||||
"no-async-foreach": noAsyncForeach,
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
ecmaVersion: 5,
|
||||
sourceType: "module",
|
||||
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
},
|
||||
|
||||
settings: {
|
||||
"import/resolver": {
|
||||
node: {
|
||||
moduleDirectory: ["node_modules", "src"],
|
||||
},
|
||||
|
||||
typescript: {},
|
||||
},
|
||||
"import/ignore": ["sinon", "uuid", "@octokit/plugin-retry"],
|
||||
},
|
||||
|
||||
rules: {
|
||||
"filenames/match-regex": ["error", "^[a-z0-9-]+(\\.test)?$"],
|
||||
"i18n-text/no-en": "off",
|
||||
|
||||
"import/extensions": [
|
||||
"error",
|
||||
{
|
||||
json: {},
|
||||
},
|
||||
],
|
||||
|
||||
"import/no-amd": "error",
|
||||
"import/no-commonjs": "error",
|
||||
"import/no-cycle": "error",
|
||||
"import/no-dynamic-require": "error",
|
||||
|
||||
"import/no-extraneous-dependencies": [
|
||||
"error",
|
||||
{
|
||||
devDependencies: true,
|
||||
},
|
||||
],
|
||||
|
||||
"import/no-namespace": "off",
|
||||
"import/no-unresolved": "error",
|
||||
"import/no-webpack-loader-syntax": "error",
|
||||
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
alphabetize: {
|
||||
order: "asc",
|
||||
},
|
||||
|
||||
"newlines-between": "always",
|
||||
},
|
||||
],
|
||||
|
||||
"max-len": [
|
||||
"error",
|
||||
{
|
||||
code: 120,
|
||||
ignoreUrls: true,
|
||||
ignoreStrings: true,
|
||||
ignoreTemplateLiterals: true,
|
||||
},
|
||||
],
|
||||
|
||||
"no-async-foreach/no-async-foreach": "error",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": "off",
|
||||
"@typescript-eslint/no-shadow": "error",
|
||||
"one-var": ["error", "never"],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["**/*.ts", "**/*.js"],
|
||||
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/prefer-regexp-exec": "off",
|
||||
"@typescript-eslint/require-await": "off",
|
||||
"@typescript-eslint/restrict-template-expressions": "off",
|
||||
"func-style": "off",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -139,7 +139,9 @@ inputs:
|
||||
outputs:
|
||||
codeql-path:
|
||||
description: The path of the CodeQL binary used for analysis
|
||||
codeql-version:
|
||||
description: The version of the CodeQL binary used for analysis
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: '../lib/init-action.js'
|
||||
post: '../lib/init-action-post.js'
|
||||
|
||||
20
lib/analyze-action.js
generated
20
lib/analyze-action.js
generated
@@ -108,7 +108,7 @@ function doesGoExtractionOutputExist(config) {
|
||||
* - We approximate whether manual build steps are present by looking at
|
||||
* whether any extraction output already exists for Go.
|
||||
*/
|
||||
async function runAutobuildIfLegacyGoWorkflow(config, features, logger) {
|
||||
async function runAutobuildIfLegacyGoWorkflow(config, logger) {
|
||||
if (!config.languages.includes(languages_1.Language.go)) {
|
||||
return;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ async function runAutobuildIfLegacyGoWorkflow(config, features, logger) {
|
||||
return;
|
||||
}
|
||||
logger.debug("Running Go autobuild because extraction output (TRAP files) for Go code has not been found.");
|
||||
await (0, autobuild_1.runAutobuild)(config, languages_1.Language.go, features, logger);
|
||||
await (0, autobuild_1.runAutobuild)(config, languages_1.Language.go, logger);
|
||||
}
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
@@ -170,8 +170,8 @@ async function run() {
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, actionsUtil.getTemporaryDirectory(), logger);
|
||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"], logger);
|
||||
await (0, analyze_1.warnIfGoInstalledAfterInit)(config, logger);
|
||||
await runAutobuildIfLegacyGoWorkflow(config, features, logger);
|
||||
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, codeql, config, features, logger);
|
||||
await runAutobuildIfLegacyGoWorkflow(config, logger);
|
||||
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, codeql, config, logger);
|
||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger, features);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ async function run() {
|
||||
core.setOutput("sarif-output", path_1.default.resolve(outputDir));
|
||||
const uploadInput = actionsUtil.getOptionalInput("upload");
|
||||
if (runStats && actionsUtil.getUploadValue(uploadInput) === "always") {
|
||||
uploadResult = await uploadLib.uploadFromActions(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), logger);
|
||||
uploadResult = await uploadLib.uploadFiles(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), features, logger);
|
||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||
}
|
||||
else {
|
||||
@@ -220,13 +220,9 @@ async function run() {
|
||||
hasBadExpectErrorInput()) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
if (error instanceof analyze_1.CodeQLAnalysisError) {
|
||||
const stats = { ...error.queriesStatusReport };
|
||||
await sendStatusReport(startedAt, config, stats, error, trapCacheUploadTime, dbCreationTimings, didUploadTrapCaches, trapCacheCleanupTelemetry, logger);
|
||||
}
|
||||
else {
|
||||
await sendStatusReport(startedAt, config, undefined, error, trapCacheUploadTime, dbCreationTimings, didUploadTrapCaches, trapCacheCleanupTelemetry, logger);
|
||||
}
|
||||
await sendStatusReport(startedAt, config, error instanceof analyze_1.CodeQLAnalysisError
|
||||
? error.queriesStatusReport
|
||||
: undefined, error instanceof analyze_1.CodeQLAnalysisError ? error.error : error, trapCacheUploadTime, dbCreationTimings, didUploadTrapCaches, trapCacheCleanupTelemetry, logger);
|
||||
return;
|
||||
}
|
||||
if (runStats && uploadResult) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
12
lib/analyze.js
generated
12
lib/analyze.js
generated
@@ -51,10 +51,12 @@ const upload_lib_1 = require("./upload-lib");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
class CodeQLAnalysisError extends Error {
|
||||
constructor(queriesStatusReport, message) {
|
||||
constructor(queriesStatusReport, message, error) {
|
||||
super(message);
|
||||
this.name = "CodeQLAnalysisError";
|
||||
this.queriesStatusReport = queriesStatusReport;
|
||||
this.message = message;
|
||||
this.error = error;
|
||||
this.name = "CodeQLAnalysisError";
|
||||
}
|
||||
}
|
||||
exports.CodeQLAnalysisError = CodeQLAnalysisError;
|
||||
@@ -184,7 +186,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
||||
}
|
||||
catch (e) {
|
||||
statusReport.analyze_failure_language = language;
|
||||
throw new CodeQLAnalysisError(statusReport, `Error running analysis for ${language}: ${util.wrapError(e).message}`);
|
||||
throw new CodeQLAnalysisError(statusReport, `Error running analysis for ${language}: ${util.wrapError(e).message}`, util.wrapError(e));
|
||||
}
|
||||
}
|
||||
return statusReport;
|
||||
@@ -217,7 +219,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
||||
return await codeql.databasePrintBaseline(databasePath);
|
||||
}
|
||||
}
|
||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, codeql, config, features, logger) {
|
||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, codeql, config, logger) {
|
||||
try {
|
||||
await (0, del_1.default)(outputDir, { force: true });
|
||||
}
|
||||
@@ -230,7 +232,7 @@ async function runFinalize(outputDir, threadsFlag, memoryFlag, codeql, config, f
|
||||
const timings = await finalizeDatabaseCreation(codeql, config, threadsFlag, memoryFlag, logger);
|
||||
// If we didn't already end tracing in the autobuild Action, end it now.
|
||||
if (process.env[environment_1.EnvVar.AUTOBUILD_DID_COMPLETE_SUCCESSFULLY] !== "true") {
|
||||
await (0, tracer_config_1.endTracingForCluster)(codeql, config, logger, features);
|
||||
await (0, tracer_config_1.endTracingForCluster)(codeql, config, logger);
|
||||
}
|
||||
return timings;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
7
lib/api-client.js
generated
7
lib/api-client.js
generated
@@ -123,6 +123,13 @@ async function getWorkflowRelativePath() {
|
||||
run_id,
|
||||
});
|
||||
const workflowUrl = runsResponse.data.workflow_url;
|
||||
const requiredWorkflowRegex = /\/repos\/[^/]+\/[^/]+\/actions\/required_workflows\/[^/]+/;
|
||||
if (!workflowUrl || requiredWorkflowRegex.test(workflowUrl)) {
|
||||
// For required workflows, the workflowUrl is invalid so we cannot fetch more informations
|
||||
// about the workflow.
|
||||
// However, the path is available in the original response.
|
||||
return runsResponse.data.path;
|
||||
}
|
||||
const workflowResponse = await apiClient.request(`GET ${workflowUrl}`);
|
||||
return workflowResponse.data.path;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{ "maximumVersion": "3.14", "minimumVersion": "3.9" }
|
||||
{ "maximumVersion": "3.14", "minimumVersion": "3.10" }
|
||||
|
||||
8
lib/autobuild-action.js
generated
8
lib/autobuild-action.js
generated
@@ -30,9 +30,7 @@ const autobuild_1 = require("./autobuild");
|
||||
const codeql_1 = require("./codeql");
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const environment_1 = require("./environment");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
const status_report_1 = require("./status-report");
|
||||
const tracer_config_1 = require("./tracer-config");
|
||||
const util_1 = require("./util");
|
||||
@@ -63,8 +61,6 @@ async function run() {
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger);
|
||||
(0, util_1.checkActionVersion)((0, actions_util_1.getActionVersion)(), gitHubVersion);
|
||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), logger);
|
||||
config = await (0, config_utils_1.getConfig)((0, actions_util_1.getTemporaryDirectory)(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||
@@ -79,12 +75,12 @@ async function run() {
|
||||
}
|
||||
for (const language of languages) {
|
||||
currentLanguage = language;
|
||||
await (0, autobuild_1.runAutobuild)(config, language, features, logger);
|
||||
await (0, autobuild_1.runAutobuild)(config, language, logger);
|
||||
}
|
||||
}
|
||||
// End tracing early to avoid tracing analyze. This improves the performance and reliability of
|
||||
// the analyze step.
|
||||
await (0, tracer_config_1.endTracingForCluster)(codeql, config, logger, features);
|
||||
await (0, tracer_config_1.endTracingForCluster)(codeql, config, logger);
|
||||
}
|
||||
catch (unwrappedError) {
|
||||
const error = (0, util_1.wrapError)(unwrappedError);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,iDAIwB;AACxB,6CAAgD;AAChD,2CAAwE;AACxE,qCAAqC;AACrC,iDAAmD;AACnD,+CAAuC;AACvC,mDAA2C;AAE3C,uCAAqD;AACrD,6CAAkD;AAClD,mDAMyB;AACzB,mDAAuD;AACvD,iCAOgB;AAShB,KAAK,UAAU,yBAAyB,CACtC,MAA0B,EAC1B,MAAc,EACd,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;IAEb,IAAA,4BAAqB,EAAC,IAAA,+BAAgB,GAAE,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAG,IAAA,gCAAgB,EAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,MAAM,IAAA,sCAAsB,EACnD,0BAAU,CAAC,SAAS,EACpB,MAAM,EACN,SAAS,EACT,MAAM,EACN,MAAM,IAAA,qBAAc,EAAC,MAAM,CAAC,EAC5B,MAAM,EACN,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,KAAK,CACb,CAAC;IACF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,YAAY,GAA0B;YAC1C,GAAG,gBAAgB;YACnB,mBAAmB,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;YAC3C,iBAAiB,EAAE,eAAe;SACnC,CAAC;QACF,MAAM,IAAA,gCAAgB,EAAC,YAAY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AAC;QACf,IAAI,CAAC,SAAS,CAAC,4BAA4B,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,iDAIwB;AACxB,6CAAgD;AAChD,2CAAwE;AACxE,qCAAqC;AACrC,iDAAmD;AACnD,+CAAuC;AAEvC,uCAAqD;AACrD,mDAMyB;AACzB,mDAAuD;AACvD,iCAMgB;AAShB,KAAK,UAAU,yBAAyB,CACtC,MAA0B,EAC1B,MAAc,EACd,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;IAEb,IAAA,4BAAqB,EAAC,IAAA,+BAAgB,GAAE,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAG,IAAA,gCAAgB,EAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,MAAM,IAAA,sCAAsB,EACnD,0BAAU,CAAC,SAAS,EACpB,MAAM,EACN,SAAS,EACT,MAAM,EACN,MAAM,IAAA,qBAAc,EAAC,MAAM,CAAC,EAC5B,MAAM,EACN,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,KAAK,CACb,CAAC;IACF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,YAAY,GAA0B;YAC1C,GAAG,gBAAgB;YACnB,mBAAmB,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;YAC3C,iBAAiB,EAAE,eAAe;SACnC,CAAC;QACF,MAAM,IAAA,gCAAgB,EAAC,YAAY,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,I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AM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,eAAe,GAAG,QAAQ,CAAC;gBAC3B,MAAM,IAAA,wBAAY,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QAED,+FAA+F;QAC/F,oBAAoB;QACpB,MAAM,IAAA,oCAAoB,EAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,cAAc,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,IAAA,gBAAS,EAAC,cAAc,CAAC,CAAC;QACxC,IAAI,CAAC,SAAS,CACZ,kIAAkI,KAAK,CAAC,OAAO,EAAE,CAClJ,CAAC;QACF,MAAM,yBAAyB,CAC7B,MAAM,EACN,MAAM,EACN,SAAS,EACT,SAAS,IAAI,EAAE,EACf,eAAe,EACf,KAAK,CACN,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,CAAC,cAAc,CAAC,oBAAM,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IAExE,MAAM,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,4BAA4B,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
13
lib/autobuild.js
generated
13
lib/autobuild.js
generated
@@ -30,6 +30,7 @@ const core = __importStar(require("@actions/core"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const codeql_1 = require("./codeql");
|
||||
const doc_url_1 = require("./doc-url");
|
||||
const environment_1 = require("./environment");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
@@ -103,15 +104,13 @@ async function determineAutobuildLanguages(codeql, config, logger) {
|
||||
logger.warning(`We will only automatically build ${languages.join(" and ")} code. If you wish to scan ${autobuildLanguagesWithoutGo
|
||||
.slice(1)
|
||||
.join(" and ")}, you must replace the autobuild step of your workflow with custom build steps. ` +
|
||||
"For more information, see " +
|
||||
"https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language");
|
||||
`See ${doc_url_1.DocUrl.SPECIFY_BUILD_STEPS_MANUALLY} for more information.`);
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
async function setupCppAutobuild(codeql, logger) {
|
||||
const envVar = feature_flags_1.featureConfig[feature_flags_1.Feature.CppDependencyInstallation].envVar;
|
||||
const featureName = "C++ automatic installation of dependencies";
|
||||
const envDoc = "https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow";
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), logger);
|
||||
@@ -120,12 +119,12 @@ async function setupCppAutobuild(codeql, logger) {
|
||||
if (process.env["RUNNER_ENVIRONMENT"] === "self-hosted" &&
|
||||
process.env[envVar] !== "true") {
|
||||
logger.info(`Disabling ${featureName} as we are on a self-hosted runner.${(0, actions_util_1.getWorkflowEventName)() !== "dynamic"
|
||||
? ` To override this, set the ${envVar} environment variable to 'true' in your workflow (see ${envDoc}).`
|
||||
? ` To override this, set the ${envVar} environment variable to 'true' in your workflow. See ${doc_url_1.DocUrl.DEFINE_ENV_VARIABLES} for more information.`
|
||||
: ""}`);
|
||||
core.exportVariable(envVar, "false");
|
||||
}
|
||||
else {
|
||||
logger.info(`Enabling ${featureName}. This can be disabled by setting the ${envVar} environment variable to 'false' (see ${envDoc}).`);
|
||||
logger.info(`Enabling ${featureName}. This can be disabled by setting the ${envVar} environment variable to 'false'. See ${doc_url_1.DocUrl.DEFINE_ENV_VARIABLES} for more information.`);
|
||||
core.exportVariable(envVar, "true");
|
||||
}
|
||||
}
|
||||
@@ -134,14 +133,14 @@ async function setupCppAutobuild(codeql, logger) {
|
||||
core.exportVariable(envVar, "false");
|
||||
}
|
||||
}
|
||||
async function runAutobuild(config, language, features, logger) {
|
||||
async function runAutobuild(config, language, logger) {
|
||||
logger.startGroup(`Attempting to automatically build ${language} code`);
|
||||
const codeQL = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
if (language === languages_1.Language.cpp) {
|
||||
await setupCppAutobuild(codeQL, logger);
|
||||
}
|
||||
if (config.buildMode &&
|
||||
(await features.getValue(feature_flags_1.Feature.AutobuildDirectTracing, codeQL))) {
|
||||
(await codeQL.supportsFeature(tools_features_1.ToolsFeature.TraceCommandUseBuildMode))) {
|
||||
await codeQL.extractUsingBuildMode(config, language);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"autobuild.js","sourceRoot":"","sources":["../src/autobuild.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,kEAgGC;AAED,8CAuCC;AAED,oCAuBC;AArLD,oDAAsC;AAEtC,iDAA6E;AAC7E,6CAAgD;AAChD,qCAA6C;AAE7C,+CAAuC;AACvC,mDAKyB;AACzB,2CAAyD;AAEzD,6CAAkD;AAClD,qDAAgD;AAChD,iCAAwD;AAEjD,KAAK,UAAU,2BAA2B,CAC/C,MAAc,EACd,MAA0B,EAC1B,MAAc;IAEd,IACE,CAAC,MAAM,CAAC,SAAS,KAAK,gBAAS,CAAC,IAAI;QAClC,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,6BAA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C1C,CAAC;IACD,IACE,MAAM,CAAC,SAAS;QAChB,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,6BAAY,CAAC,wBAAwB,CAAC,CAAC,EACrE,CAAC;QACD,MAAM,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,QAAQ,KAAK,oBAAQ,CAAC,EAAE,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,CAAC,oBAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC"}
|
||||
19
lib/cli-errors.js
generated
19
lib/cli-errors.js
generated
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cliErrorsConfig = exports.CliConfigErrorCategory = exports.CommandInvocationError = void 0;
|
||||
exports.getCliConfigCategoryIfExists = getCliConfigCategoryIfExists;
|
||||
exports.wrapCliConfigurationError = wrapCliConfigurationError;
|
||||
const doc_url_1 = require("./doc-url");
|
||||
const util_1 = require("./util");
|
||||
/**
|
||||
* A class of Error that we can classify as an error stemming from a CLI
|
||||
@@ -19,20 +20,16 @@ class CommandInvocationError extends Error {
|
||||
if (fatalErrors) {
|
||||
message =
|
||||
`Encountered a fatal error while running "${prettyCommand}". ` +
|
||||
`Exit code was ${exitCode} and error was: ${fatalErrors.trim()} See the logs for more details.`;
|
||||
`Exit code was ${exitCode} and error was: ${ensureEndsInPeriod(fatalErrors.trim())} See the logs for more details.`;
|
||||
}
|
||||
else if (autobuildErrors) {
|
||||
const autobuildHelpLink = "https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed";
|
||||
message =
|
||||
"We were unable to automatically build your code. Please provide manual build steps. " +
|
||||
`For more information, see ${autobuildHelpLink}. ` +
|
||||
`See ${doc_url_1.DocUrl.AUTOMATIC_BUILD_FAILED} for more information. ` +
|
||||
`Encountered the following error: ${autobuildErrors}`;
|
||||
}
|
||||
else {
|
||||
let lastLine = stderr.trim().split("\n").pop()?.trim() || "";
|
||||
if (lastLine[lastLine.length - 1] !== ".") {
|
||||
lastLine += ".";
|
||||
}
|
||||
const lastLine = ensureEndsInPeriod(stderr.trim().split("\n").pop()?.trim() || "n/a");
|
||||
message =
|
||||
`Encountered a fatal error while running "${prettyCommand}". ` +
|
||||
`Exit code was ${exitCode} and last log line was: ${lastLine} See the logs for more details.`;
|
||||
@@ -74,7 +71,7 @@ exports.CommandInvocationError = CommandInvocationError;
|
||||
* the Actions UI.
|
||||
*/
|
||||
function extractFatalErrors(error) {
|
||||
const fatalErrorRegex = /.*fatal error occurred:/gi;
|
||||
const fatalErrorRegex = /.*fatal (internal )?error occurr?ed(. Details)?:/gi;
|
||||
let fatalErrors = [];
|
||||
let lastFatalErrorIndex;
|
||||
let match;
|
||||
@@ -118,6 +115,7 @@ function ensureEndsInPeriod(text) {
|
||||
/** Error messages from the CLI that we consider configuration errors and handle specially. */
|
||||
var CliConfigErrorCategory;
|
||||
(function (CliConfigErrorCategory) {
|
||||
CliConfigErrorCategory["AutobuildError"] = "AutobuildError";
|
||||
CliConfigErrorCategory["ExternalRepositoryCloneFailed"] = "ExternalRepositoryCloneFailed";
|
||||
CliConfigErrorCategory["GradleBuildFailed"] = "GradleBuildFailed";
|
||||
CliConfigErrorCategory["IncompatibleWithActionVersion"] = "IncompatibleWithActionVersion";
|
||||
@@ -141,6 +139,11 @@ var CliConfigErrorCategory;
|
||||
* would like to categorize an error as a configuration error or not.
|
||||
*/
|
||||
exports.cliErrorsConfig = {
|
||||
[CliConfigErrorCategory.AutobuildError]: {
|
||||
cliErrorMessageCandidates: [
|
||||
new RegExp("We were unable to automatically build your code"),
|
||||
],
|
||||
},
|
||||
[CliConfigErrorCategory.ExternalRepositoryCloneFailed]: {
|
||||
cliErrorMessageCandidates: [
|
||||
new RegExp("Failed to clone external Git repository"),
|
||||
|
||||
File diff suppressed because one or more lines are too long
14
lib/codeql.js
generated
14
lib/codeql.js
generated
@@ -42,6 +42,7 @@ const yaml = __importStar(require("js-yaml"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const cli_errors_1 = require("./cli-errors");
|
||||
const doc_url_1 = require("./doc-url");
|
||||
const environment_1 = require("./environment");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const setupCodeql = __importStar(require("./setup-codeql"));
|
||||
@@ -66,15 +67,15 @@ const CODEQL_MINIMUM_VERSION = "2.12.6";
|
||||
/**
|
||||
* This version will shortly become the oldest version of CodeQL that the Action will run with.
|
||||
*/
|
||||
const CODEQL_NEXT_MINIMUM_VERSION = "2.12.6";
|
||||
const CODEQL_NEXT_MINIMUM_VERSION = "2.13.5";
|
||||
/**
|
||||
* This is the version of GHES that was most recently deprecated.
|
||||
*/
|
||||
const GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.8";
|
||||
const GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.9";
|
||||
/**
|
||||
* This is the deprecation date for the version of GHES that was most recently deprecated.
|
||||
*/
|
||||
const GHES_MOST_RECENT_DEPRECATION_DATE = "2024-03-26";
|
||||
const GHES_MOST_RECENT_DEPRECATION_DATE = "2024-07-09";
|
||||
/** The CLI verbosity level to use for extraction in debug mode. */
|
||||
const EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++";
|
||||
/*
|
||||
@@ -259,9 +260,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
async supportsFeature(feature) {
|
||||
return (0, tools_features_1.isSupportedToolsFeature)(await this.getVersion(), feature);
|
||||
},
|
||||
async databaseInitCluster(config, sourceRoot, processName, qlconfigFile, features, logger) {
|
||||
async databaseInitCluster(config, sourceRoot, processName, qlconfigFile, logger) {
|
||||
const extraArgs = config.languages.map((language) => `--language=${language}`);
|
||||
if (await (0, tracer_config_1.shouldEnableIndirectTracing)(codeql, config, features)) {
|
||||
if (await (0, tracer_config_1.shouldEnableIndirectTracing)(codeql, config)) {
|
||||
extraArgs.push("--begin-tracing");
|
||||
extraArgs.push(...(await getTrapCachingExtractorConfigArgs(config)));
|
||||
extraArgs.push(`--trace-process-name=${processName}`);
|
||||
@@ -360,8 +361,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
if (config.buildMode === util_1.BuildMode.Autobuild) {
|
||||
const prefix = "We were unable to automatically build your code. " +
|
||||
"Please change the build mode for this language to manual and specify build steps " +
|
||||
"for your project. For more information, see " +
|
||||
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed.";
|
||||
`for your project. See ${doc_url_1.DocUrl.AUTOMATIC_BUILD_FAILED} for more information.`;
|
||||
const ErrorConstructor = e instanceof util.ConfigurationError
|
||||
? util.ConfigurationError
|
||||
: Error;
|
||||
|
||||
File diff suppressed because one or more lines are too long
38
lib/codeql.test.js
generated
38
lib/codeql.test.js
generated
@@ -40,6 +40,7 @@ const actionsUtil = __importStar(require("./actions-util"));
|
||||
const cli_errors_1 = require("./cli-errors");
|
||||
const codeql = __importStar(require("./codeql"));
|
||||
const defaults = __importStar(require("./defaults.json"));
|
||||
const doc_url_1 = require("./doc-url");
|
||||
const languages_1 = require("./languages");
|
||||
const logging_1 = require("./logging");
|
||||
const setup_codeql_1 = require("./setup-codeql");
|
||||
@@ -315,7 +316,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
||||
tempDir,
|
||||
augmentationProperties,
|
||||
};
|
||||
await codeqlObject.databaseInitCluster(thisStubConfig, "", undefined, undefined, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
|
||||
await codeqlObject.databaseInitCluster(thisStubConfig, "", undefined, undefined, (0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should have used an config file
|
||||
const configArg = args.find((arg) => arg.startsWith("--codescanning-config="));
|
||||
@@ -451,7 +452,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.12.6"));
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, "/path/to/qlconfig.yml", (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, "/path/to/qlconfig.yml", (0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should have used a config file
|
||||
const hasCodeScanningConfigArg = args.some((arg) => arg.startsWith("--codescanning-config="));
|
||||
@@ -467,7 +468,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.12.6"));
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, undefined, // undefined qlconfigFile
|
||||
(0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
|
||||
(0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
const hasQlconfigArg = args.some((arg) => arg.startsWith("--qlconfig-file="));
|
||||
t.false(hasQlconfigArg, "should NOT have injected a qlconfig");
|
||||
@@ -574,10 +575,9 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), {
|
||||
instanceOf: cli_errors_1.CommandInvocationError,
|
||||
instanceOf: util.ConfigurationError,
|
||||
message: "We were unable to automatically build your code. Please provide manual build steps. " +
|
||||
"For more information, see " +
|
||||
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed. " +
|
||||
`See ${doc_url_1.DocUrl.AUTOMATIC_BUILD_FAILED} for more information. ` +
|
||||
"Encountered the following error: Start of the error message\n" +
|
||||
" Some more context about the error message\n" +
|
||||
" continued\n" +
|
||||
@@ -593,14 +593,32 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), {
|
||||
instanceOf: cli_errors_1.CommandInvocationError,
|
||||
instanceOf: util.ConfigurationError,
|
||||
message: "We were unable to automatically build your code. Please provide manual build steps. " +
|
||||
"For more information, see " +
|
||||
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed. " +
|
||||
`See ${doc_url_1.DocUrl.AUTOMATIC_BUILD_FAILED} for more information. ` +
|
||||
"Encountered the following error: " +
|
||||
`${Array.from({ length: 10 }, (_, i) => `line${i + 1}`).join("\n")}\n(truncated)`,
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("runTool recognizes fatal internal errors", async (t) => {
|
||||
const stderr = `
|
||||
[11/31 eval 8m19s] Evaluation done; writing results to codeql/go-queries/Security/CWE-020/MissingRegexpAnchor.bqrs.
|
||||
Oops! A fatal internal error occurred. Details:
|
||||
com.semmle.util.exception.CatastrophicError: An error occurred while evaluating ControlFlowGraph::ControlFlow::Root.isRootOf/1#dispred#f610e6ed/2@86282cc8
|
||||
Severe disk cache trouble (corruption or out of space) at /home/runner/work/_temp/codeql_databases/go/db-go/default/cache/pages/28/33.pack: Failed to write item to disk`;
|
||||
stubToolRunnerConstructor(1, stderr);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.12.6"));
|
||||
sinon.stub(codeqlObject, "resolveExtractor").resolves("/path/to/extractor");
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await t.throwsAsync(async () => await codeqlObject.databaseRunQueries(stubConfig.dbLocation, []), {
|
||||
instanceOf: cli_errors_1.CommandInvocationError,
|
||||
message: `Encountered a fatal error while running "codeql-for-testing database run-queries --expect-discarded-cache --min-disk-free=1024 -v". Exit code was 1 and error was: Oops! A fatal internal error occurred. Details:
|
||||
com.semmle.util.exception.CatastrophicError: An error occurred while evaluating ControlFlowGraph::ControlFlow::Root.isRootOf/1#dispred#f610e6ed/2@86282cc8
|
||||
Severe disk cache trouble (corruption or out of space) at /home/runner/work/_temp/codeql_databases/go/db-go/default/cache/pages/28/33.pack: Failed to write item to disk. See the logs for more details.`,
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("runTool outputs last line of stderr if fatal error could not be found", async (t) => {
|
||||
const cliStderr = "line1\nline2\nline3\nline4\nline5";
|
||||
stubToolRunnerConstructor(32, cliStderr);
|
||||
@@ -622,7 +640,7 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
process.env["CODEQL_ACTION_EXTRA_OPTIONS"] =
|
||||
'{ "database": { "init": ["--overwrite"] } }';
|
||||
await codeqlObject.databaseInitCluster(stubConfig, "sourceRoot", undefined, undefined, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(false));
|
||||
await codeqlObject.databaseInitCluster(stubConfig, "sourceRoot", undefined, undefined, (0, logging_1.getRunnerLogger)(false));
|
||||
t.true(runnerConstructorStub.calledOnce);
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
t.is(args.filter((option) => option === "--overwrite").length, 1, "--overwrite should only be passed once");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-v2.17.6",
|
||||
"cliVersion": "2.17.6",
|
||||
"priorBundleVersion": "codeql-bundle-v2.17.5",
|
||||
"priorCliVersion": "2.17.5"
|
||||
"bundleVersion": "codeql-bundle-v2.18.1",
|
||||
"cliVersion": "2.18.1",
|
||||
"priorBundleVersion": "codeql-bundle-v2.18.0",
|
||||
"priorCliVersion": "2.18.0"
|
||||
}
|
||||
|
||||
16
lib/doc-url.js
generated
Normal file
16
lib/doc-url.js
generated
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
/**
|
||||
* URLs to code scanning docs linked to from CodeQL Action logs.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DocUrl = void 0;
|
||||
var DocUrl;
|
||||
(function (DocUrl) {
|
||||
DocUrl["ASSIGNING_PERMISSIONS_TO_JOBS"] = "https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs";
|
||||
DocUrl["AUTOMATIC_BUILD_FAILED"] = "https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed";
|
||||
DocUrl["DEFINE_ENV_VARIABLES"] = "https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow";
|
||||
DocUrl["SCANNING_ON_PUSH"] = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push";
|
||||
DocUrl["SPECIFY_BUILD_STEPS_MANUALLY"] = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#about-specifying-build-steps-manually";
|
||||
DocUrl["TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS"] = "https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs";
|
||||
})(DocUrl || (exports.DocUrl = DocUrl = {}));
|
||||
//# sourceMappingURL=doc-url.js.map
|
||||
1
lib/doc-url.js.map
Normal file
1
lib/doc-url.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"doc-url.js","sourceRoot":"","sources":["../src/doc-url.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,IAAY,MAOX;AAPD,WAAY,MAAM;IAChB,uHAA6G,CAAA;IAC7G,gJAAsI,CAAA;IACtI,yJAA+I,CAAA;IAC/I,qMAA2L,CAAA;IAC3L,gOAAsN,CAAA;IACtN,2PAAiP,CAAA;AACnP,CAAC,EAPW,MAAM,sBAAN,MAAM,QAOjB"}
|
||||
8
lib/feature-flags.js
generated
8
lib/feature-flags.js
generated
@@ -29,7 +29,6 @@ const path = __importStar(require("path"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const api_client_1 = require("./api-client");
|
||||
const defaults = __importStar(require("./defaults.json"));
|
||||
const tools_features_1 = require("./tools-features");
|
||||
const util = __importStar(require("./util"));
|
||||
const DEFAULT_VERSION_FEATURE_FLAG_PREFIX = "default_codeql_version_";
|
||||
const DEFAULT_VERSION_FEATURE_FLAG_SUFFIX = "_enabled";
|
||||
@@ -49,7 +48,6 @@ exports.CODEQL_VERSION_FINE_GRAINED_PARALLELISM = "2.15.1";
|
||||
*/
|
||||
var Feature;
|
||||
(function (Feature) {
|
||||
Feature["AutobuildDirectTracing"] = "autobuild_direct_tracing_v2";
|
||||
Feature["CleanupTrapCaches"] = "cleanup_trap_caches";
|
||||
Feature["CppDependencyInstallation"] = "cpp_dependency_installation_enabled";
|
||||
Feature["DisableCsharpBuildless"] = "disable_csharp_buildless";
|
||||
@@ -59,12 +57,6 @@ var Feature;
|
||||
Feature["QaTelemetryEnabled"] = "qa_telemetry_enabled";
|
||||
})(Feature || (exports.Feature = Feature = {}));
|
||||
exports.featureConfig = {
|
||||
[Feature.AutobuildDirectTracing]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_AUTOBUILD_BUILD_MODE_DIRECT_TRACING",
|
||||
minimumVersion: undefined,
|
||||
toolsFeature: tools_features_1.ToolsFeature.TraceCommandUseBuildMode,
|
||||
},
|
||||
[Feature.CleanupTrapCaches]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES",
|
||||
|
||||
File diff suppressed because one or more lines are too long
12
lib/feature-flags.test.js
generated
12
lib/feature-flags.test.js
generated
@@ -196,18 +196,6 @@ for (const feature of Object.keys(feature_flags_1.featureConfig)) {
|
||||
});
|
||||
}
|
||||
}
|
||||
// If we ever run into a situation where we no longer have any features that
|
||||
// specify a minimum version or required tools feature, then we will have a
|
||||
// bunch of code no longer being tested. This is unlikely, and this test will
|
||||
// fail if that happens.
|
||||
// If we do end up in that situation, then we should consider adding a synthetic
|
||||
// feature with a minimum version that is only used for tests.
|
||||
(0, ava_1.default)("At least one feature has a minimum version specified", (t) => {
|
||||
t.assert(Object.values(feature_flags_1.featureConfig).some((f) => f.minimumVersion !== undefined), "At least one feature should have a minimum version specified");
|
||||
t.assert(Object.values(feature_flags_1.featureConfig).some((f) => f.toolsFeature !== undefined), "At least one feature should have a required tools feature specified");
|
||||
// An even less likely scenario is that we no longer have any features.
|
||||
t.assert(Object.values(feature_flags_1.featureConfig).length > 0, "There should be at least one feature");
|
||||
});
|
||||
(0, ava_1.default)("Feature flags are saved to disk", async (t) => {
|
||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
|
||||
File diff suppressed because one or more lines are too long
3
lib/fingerprints.js
generated
3
lib/fingerprints.js
generated
@@ -32,6 +32,7 @@ exports.addFingerprints = addFingerprints;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const long_1 = __importDefault(require("long"));
|
||||
const doc_url_1 = require("./doc-url");
|
||||
const tab = "\t".charCodeAt(0);
|
||||
const space = " ".charCodeAt(0);
|
||||
const lf = "\n".charCodeAt(0);
|
||||
@@ -238,7 +239,7 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
|
||||
// Compute fingerprints for results in the given sarif file
|
||||
// and return an updated sarif file contents.
|
||||
async function addFingerprints(sarif, sourceRoot, logger) {
|
||||
logger.info("Adding fingerprints to SARIF file. For more information, see https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs");
|
||||
logger.info(`Adding fingerprints to SARIF file. See ${doc_url_1.DocUrl.TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS} for more information.`);
|
||||
// Gather together results for the same file and construct
|
||||
// callbacks to accept hashes for that file and update the location
|
||||
const callbacksByFile = {};
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
lib/init-action-post-helper.js
generated
2
lib/init-action-post-helper.js
generated
@@ -77,7 +77,7 @@ async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) {
|
||||
await codeql.databaseExportDiagnostics(databasePath, sarifFile, category, config.tempDir, logger);
|
||||
}
|
||||
logger.info(`Uploading failed SARIF file ${sarifFile}`);
|
||||
const uploadResult = await uploadLib.uploadFromActions(sarifFile, checkoutPath, category, logger);
|
||||
const uploadResult = await uploadLib.uploadFiles(sarifFile, checkoutPath, category, features, logger);
|
||||
await uploadLib.waitForProcessing(repositoryNwo, uploadResult.sarifID, logger, { isUnsuccessfulExecution: true });
|
||||
return uploadResult
|
||||
? { ...uploadResult.statusReport, sarifID: uploadResult.sarifID }
|
||||
|
||||
File diff suppressed because one or more lines are too long
8
lib/init-action-post-helper.test.js
generated
8
lib/init-action-post-helper.test.js
generated
@@ -319,8 +319,8 @@ async function testFailedSarifUpload(t, actionsWorkflow, { category, databaseExi
|
||||
const databaseExportDiagnosticsStub = sinon.stub(codeqlObject, "databaseExportDiagnostics");
|
||||
const diagnosticsExportStub = sinon.stub(codeqlObject, "diagnosticsExport");
|
||||
sinon.stub(workflow, "getWorkflow").resolves(actionsWorkflow);
|
||||
const uploadFromActions = sinon.stub(uploadLib, "uploadFromActions");
|
||||
uploadFromActions.resolves({
|
||||
const uploadFiles = sinon.stub(uploadLib, "uploadFiles");
|
||||
uploadFiles.resolves({
|
||||
sarifID: "42",
|
||||
statusReport: { raw_upload_size_bytes: 20, zipped_upload_size_bytes: 10 },
|
||||
});
|
||||
@@ -342,14 +342,14 @@ async function testFailedSarifUpload(t, actionsWorkflow, { category, databaseExi
|
||||
else {
|
||||
t.true(diagnosticsExportStub.calledOnceWith(sinon.match.string, category, config), `Actual args were: ${diagnosticsExportStub.args}`);
|
||||
}
|
||||
t.true(uploadFromActions.calledOnceWith(sinon.match.string, sinon.match.string, category, sinon.match.any), `Actual args were: ${uploadFromActions.args}`);
|
||||
t.true(uploadFiles.calledOnceWith(sinon.match.string, sinon.match.string, category, sinon.match.any, sinon.match.any), `Actual args were: ${uploadFiles.args}`);
|
||||
t.true(waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||
isUnsuccessfulExecution: true,
|
||||
}));
|
||||
}
|
||||
else {
|
||||
t.true(diagnosticsExportStub.notCalled);
|
||||
t.true(uploadFromActions.notCalled);
|
||||
t.true(uploadFiles.notCalled);
|
||||
t.true(waitForProcessing.notCalled);
|
||||
}
|
||||
return result;
|
||||
|
||||
File diff suppressed because one or more lines are too long
3
lib/init-action.js
generated
3
lib/init-action.js
generated
@@ -315,7 +315,7 @@ async function run() {
|
||||
logger.warning("The CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION environment variable is deprecated and no longer has any effect. We recommend removing any references from your workflows. See https://github.blog/changelog/2024-01-23-codeql-2-16-python-dependency-installation-disabled-new-queries-and-bug-fixes/ for more information.");
|
||||
}
|
||||
const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || "");
|
||||
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", (0, actions_util_1.getOptionalInput)("registries"), apiDetails, features, logger);
|
||||
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", (0, actions_util_1.getOptionalInput)("registries"), apiDetails, logger);
|
||||
if (tracerConfig !== undefined) {
|
||||
for (const [key, value] of Object.entries(tracerConfig.env)) {
|
||||
core.exportVariable(key, value);
|
||||
@@ -325,6 +325,7 @@ async function run() {
|
||||
// did not exist until now.
|
||||
(0, diagnostics_1.flushDiagnostics)(config);
|
||||
core.setOutput("codeql-path", config.codeQLCmd);
|
||||
core.setOutput("codeql-version", (await codeql.getVersion()).version);
|
||||
}
|
||||
catch (unwrappedError) {
|
||||
const error = (0, util_1.wrapError)(unwrappedError);
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
lib/init.js
generated
6
lib/init.js
generated
@@ -59,7 +59,7 @@ async function initConfig(inputs, codeql) {
|
||||
logger.endGroup();
|
||||
return config;
|
||||
}
|
||||
async function runInit(codeql, config, sourceRoot, processName, registriesInput, apiDetails, features, logger) {
|
||||
async function runInit(codeql, config, sourceRoot, processName, registriesInput, apiDetails, logger) {
|
||||
fs.mkdirSync(config.dbLocation, { recursive: true });
|
||||
const { registriesAuthTokens, qlconfigFile } = await configUtils.generateRegistries(registriesInput, config.tempDir, logger);
|
||||
await configUtils.wrapEnvironment({
|
||||
@@ -67,8 +67,8 @@ async function runInit(codeql, config, sourceRoot, processName, registriesInput,
|
||||
CODEQL_REGISTRIES_AUTH: registriesAuthTokens,
|
||||
},
|
||||
// Init a database cluster
|
||||
async () => await codeql.databaseInitCluster(config, sourceRoot, processName, qlconfigFile, features, logger));
|
||||
return await (0, tracer_config_1.getCombinedTracerConfig)(codeql, config, features);
|
||||
async () => await codeql.databaseInitCluster(config, sourceRoot, processName, qlconfigFile, logger));
|
||||
return await (0, tracer_config_1.getCombinedTracerConfig)(codeql, config);
|
||||
}
|
||||
function printPathFiltersWarning(config, logger) {
|
||||
// Index include/exclude/filters only work in javascript/python/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AAC,UAAU,CAAC,CAAC,MAAM,CAAC,EAC3C,CAAC;QACD,MAAM,CAAC,OAAO,CACZ,kCAAkC,MAAM,CAAC,UAAU,4CAA4C,CAChG,CAAC;QACF,IAAI,CAAC;YACH,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;gBACxB,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,CAAC;gBACb,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YAEH,MAAM,CAAC,IAAI,CACT,yCAAyC,MAAM,CAAC,UAAU,GAAG,CAC9D,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,mEACZ,IAAA,+BAAgB,EAAC,aAAa,CAAC;gBAC7B,CAAC,CAAC,sCAAsC,MAAM,CAAC,UAAU,IAAI;gBAC7D,CAAC,CAAC,kCAAkC,MAAM,CAAC,UAAU,IAAI;oBACvD,yEACN,iEAAiE,CAAC;YAElE,kGAAkG;YAClG,IAAI,IAAA,iCAAkB,GAAE,EAAE,CAAC;gBACzB,MAAM,IAAI,IAAI,CAAC,kBAAkB,CAC/B,GAAG,KAAK,4GAA4G;oBAClH,sEACE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OACpB,EAAE,CACL,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,sDAAsD;oBAC5D,+EAA+E;oBAC/E,yCACE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OACpB,EAAE,CACL,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
||||
56
lib/start-proxy-action-post.js
generated
Normal file
56
lib/start-proxy-action-post.js
generated
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* This file is the entry point for the `post:` hook of `start-proxy-action.yml`.
|
||||
* It will run after the all steps in this job, in reverse order in relation to
|
||||
* other `post:` hooks.
|
||||
*/
|
||||
const fs = __importStar(require("fs"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const configUtils = __importStar(require("./config-utils"));
|
||||
const util_1 = require("./util");
|
||||
async function runWrapper() {
|
||||
try {
|
||||
const pid = core.getState("proxy-process-pid");
|
||||
if (pid) {
|
||||
process.kill(Number(pid));
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`start-proxy post-action step failed: ${(0, util_1.wrapError)(error).message}`);
|
||||
}
|
||||
const config = await configUtils.getConfig(actionsUtil.getTemporaryDirectory(), core);
|
||||
if ((config && config.debugMode) || core.isDebug()) {
|
||||
const logFilePath = core.getState("proxy-log-file");
|
||||
if (logFilePath) {
|
||||
const readStream = fs.createReadStream(logFilePath);
|
||||
readStream.pipe(process.stdout, { end: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
void runWrapper();
|
||||
//# sourceMappingURL=start-proxy-action-post.js.map
|
||||
1
lib/start-proxy-action-post.js.map
Normal file
1
lib/start-proxy-action-post.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"start-proxy-action-post.js","sourceRoot":"","sources":["../src/start-proxy-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,uCAAyB;AAEzB,oDAAsC;AAEtC,4DAA8C;AAC9C,4DAA8C;AAC9C,iCAAmC;AAEnC,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,wCAAwC,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CACnE,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CACxC,WAAW,CAAC,qBAAqB,EAAE,EACnC,IAAI,CACL,CAAC;IAEF,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACpD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;YACpD,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
151
lib/start-proxy-action.js
generated
Normal file
151
lib/start-proxy-action.js
generated
Normal file
@@ -0,0 +1,151 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const child_process_1 = require("child_process");
|
||||
const path = __importStar(require("path"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const node_forge_1 = require("node-forge");
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const util = __importStar(require("./util"));
|
||||
const UPDATEJOB_PROXY = "update-job-proxy";
|
||||
const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912";
|
||||
const UPDATEJOB_PROXY_URL = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.18.1/update-job-proxy.tar.gz";
|
||||
const PROXY_USER = "proxy_user";
|
||||
const KEY_SIZE = 2048;
|
||||
const KEY_EXPIRY_YEARS = 2;
|
||||
const CERT_SUBJECT = [
|
||||
{
|
||||
name: "commonName",
|
||||
value: "Dependabot Internal CA",
|
||||
},
|
||||
{
|
||||
name: "organizationName",
|
||||
value: "GitHub inc.",
|
||||
},
|
||||
{
|
||||
shortName: "OU",
|
||||
value: "Dependabot",
|
||||
},
|
||||
{
|
||||
name: "countryName",
|
||||
value: "US",
|
||||
},
|
||||
{
|
||||
shortName: "ST",
|
||||
value: "California",
|
||||
},
|
||||
{
|
||||
name: "localityName",
|
||||
value: "San Francisco",
|
||||
},
|
||||
];
|
||||
function generateCertificateAuthority() {
|
||||
const keys = node_forge_1.pki.rsa.generateKeyPair(KEY_SIZE);
|
||||
const cert = node_forge_1.pki.createCertificate();
|
||||
cert.publicKey = keys.publicKey;
|
||||
cert.serialNumber = "01";
|
||||
cert.validity.notBefore = new Date();
|
||||
cert.validity.notAfter = new Date();
|
||||
cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + KEY_EXPIRY_YEARS);
|
||||
cert.setSubject(CERT_SUBJECT);
|
||||
cert.setIssuer(CERT_SUBJECT);
|
||||
cert.setExtensions([{ name: "basicConstraints", cA: true }]);
|
||||
cert.sign(keys.privateKey);
|
||||
const pem = node_forge_1.pki.certificateToPem(cert);
|
||||
const key = node_forge_1.pki.privateKeyToPem(keys.privateKey);
|
||||
return { cert: pem, key };
|
||||
}
|
||||
async function runWrapper() {
|
||||
const tempDir = actionsUtil.getTemporaryDirectory();
|
||||
const logFilePath = path.resolve(tempDir, "proxy.log");
|
||||
const input = actionsUtil.getOptionalInput("registry_secrets") || "[]";
|
||||
const credentials = JSON.parse(input);
|
||||
const ca = generateCertificateAuthority();
|
||||
const proxy_password = actionsUtil.getOptionalInput("proxy_password");
|
||||
core.saveState("proxy-log-file", logFilePath);
|
||||
let proxy_auth = undefined;
|
||||
if (proxy_password) {
|
||||
proxy_auth = {
|
||||
username: PROXY_USER,
|
||||
password: proxy_password,
|
||||
};
|
||||
}
|
||||
const proxyConfig = {
|
||||
all_credentials: credentials,
|
||||
ca,
|
||||
proxy_auth,
|
||||
};
|
||||
const host = "127.0.0.1";
|
||||
let proxyBin = toolcache.find(UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION);
|
||||
if (!proxyBin) {
|
||||
const temp = await toolcache.downloadTool(UPDATEJOB_PROXY_URL);
|
||||
const extracted = await toolcache.extractTar(temp);
|
||||
proxyBin = await toolcache.cacheDir(extracted, UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION);
|
||||
}
|
||||
proxyBin = path.join(proxyBin, UPDATEJOB_PROXY);
|
||||
let port = 49152;
|
||||
try {
|
||||
let subprocess = undefined;
|
||||
let tries = 5;
|
||||
let subprocessError = undefined;
|
||||
while (tries-- > 0 && !subprocess && !subprocessError) {
|
||||
subprocess = (0, child_process_1.spawn)(proxyBin, ["-addr", `${host}:${port}`, "-config", "-", "-logfile", logFilePath], {
|
||||
detached: true,
|
||||
stdio: ["pipe", "ignore", "ignore"],
|
||||
});
|
||||
subprocess.unref();
|
||||
if (subprocess.pid) {
|
||||
core.saveState("proxy-process-pid", `${subprocess.pid}`);
|
||||
}
|
||||
subprocess.on("error", (error) => {
|
||||
subprocessError = error;
|
||||
});
|
||||
subprocess.on("exit", (code) => {
|
||||
if (code !== 0) {
|
||||
// If the proxy failed to start, try a different port from the ephemeral range [49152, 65535]
|
||||
port = Math.floor(Math.random() * (65535 - 49152) + 49152);
|
||||
subprocess = undefined;
|
||||
}
|
||||
});
|
||||
subprocess.stdin?.write(JSON.stringify(proxyConfig));
|
||||
subprocess.stdin?.end();
|
||||
// Wait a little to allow the proxy to start
|
||||
await util.delay(1000);
|
||||
}
|
||||
if (subprocessError) {
|
||||
throw subprocessError;
|
||||
}
|
||||
core.info(`Proxy started on ${host}:${port}`);
|
||||
core.setOutput("proxy_host", host);
|
||||
core.setOutput("proxy_port", port.toString());
|
||||
core.setOutput("proxy_ca_certificate", ca.cert);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`start-proxy action failed: ${util.wrapError(error).message}`);
|
||||
}
|
||||
}
|
||||
void runWrapper();
|
||||
//# sourceMappingURL=start-proxy-action.js.map
|
||||
1
lib/start-proxy-action.js.map
Normal file
1
lib/start-proxy-action.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAE/B,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA0B3B,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;KACvB;CACF,CAAC;AAEF,SAAS,4BAA4B;IACnC,MAAM,IAAI,GAAG,gBAAG,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,gBAAG,CAAC,iBAAiB,EAAE,CAAC;IACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAChC,IAAI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I,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,8BAA8B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAC9D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
3
lib/status-report.js
generated
3
lib/status-report.js
generated
@@ -33,6 +33,7 @@ const os = __importStar(require("os"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const doc_url_1 = require("./doc-url");
|
||||
const environment_1 = require("./environment");
|
||||
const util_1 = require("./util");
|
||||
var ActionName;
|
||||
@@ -253,7 +254,7 @@ async function sendStatusReport(statusReport) {
|
||||
core.warning('Workflows triggered by Dependabot on the "push" event run with read-only access. ' +
|
||||
"Uploading Code Scanning results requires write access. " +
|
||||
'To use Code Scanning with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. ' +
|
||||
"See https://docs.github.com/en/code-security/secure-coding/configuring-code-scanning#scanning-on-push for more information on how to configure these events.");
|
||||
`See ${doc_url_1.DocUrl.SCANNING_ON_PUSH} for more information on how to configure these events.`);
|
||||
}
|
||||
else {
|
||||
core.warning(e.message);
|
||||
|
||||
File diff suppressed because one or more lines are too long
28
lib/tracer-config.js
generated
28
lib/tracer-config.js
generated
@@ -29,15 +29,22 @@ exports.getTracerConfigForCluster = getTracerConfigForCluster;
|
||||
exports.getCombinedTracerConfig = getCombinedTracerConfig;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
const tools_features_1 = require("./tools-features");
|
||||
const util_1 = require("./util");
|
||||
async function shouldEnableIndirectTracing(codeql, config, features) {
|
||||
return ((!config.buildMode ||
|
||||
config.buildMode === util_1.BuildMode.Manual ||
|
||||
!(await features.getValue(feature_flags_1.Feature.AutobuildDirectTracing, codeql))) &&
|
||||
config.languages.some((l) => (0, languages_1.isTracedLanguage)(l)));
|
||||
async function shouldEnableIndirectTracing(codeql, config) {
|
||||
// We don't need to trace build mode none, or languages which unconditionally don't need tracing.
|
||||
if (config.buildMode === util_1.BuildMode.None) {
|
||||
return false;
|
||||
}
|
||||
// If the CLI supports `trace-command` with a `--build-mode`, we'll use direct tracing instead of
|
||||
// indirect tracing.
|
||||
if (config.buildMode === util_1.BuildMode.Autobuild &&
|
||||
(await codeql.supportsFeature(tools_features_1.ToolsFeature.TraceCommandUseBuildMode))) {
|
||||
return false;
|
||||
}
|
||||
// Otherwise, use direct tracing if any of the languages need to be traced.
|
||||
return config.languages.some((l) => (0, languages_1.isTracedLanguage)(l));
|
||||
}
|
||||
/**
|
||||
* Delete variables as specified by the end-tracing script
|
||||
@@ -48,8 +55,8 @@ async function shouldEnableIndirectTracing(codeql, config, features) {
|
||||
*
|
||||
* However, it will stop tracing for all steps past the current build step.
|
||||
*/
|
||||
async function endTracingForCluster(codeql, config, logger, features) {
|
||||
if (!(await shouldEnableIndirectTracing(codeql, config, features)))
|
||||
async function endTracingForCluster(codeql, config, logger) {
|
||||
if (!(await shouldEnableIndirectTracing(codeql, config)))
|
||||
return;
|
||||
logger.info("Unsetting build tracing environment variables. Subsequent steps of this job will not be traced.");
|
||||
const envVariablesFile = path.resolve(config.dbLocation, "temp/tracingEnvironment/end-tracing.json");
|
||||
@@ -77,9 +84,10 @@ async function getTracerConfigForCluster(config) {
|
||||
env: tracingEnvVariables,
|
||||
};
|
||||
}
|
||||
async function getCombinedTracerConfig(codeql, config, features) {
|
||||
if (!(await shouldEnableIndirectTracing(codeql, config, features)))
|
||||
async function getCombinedTracerConfig(codeql, config) {
|
||||
if (!(await shouldEnableIndirectTracing(codeql, config))) {
|
||||
return undefined;
|
||||
}
|
||||
const mainTracerConfig = await getTracerConfigForCluster(config);
|
||||
// If the CLI doesn't yet support setting the CODEQL_RUNNER environment variable to
|
||||
// the runner executable path, we set it here in the Action.
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"tracer-config.js","sourceRoot":"","sources":["../src/tracer-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAeA,kEAWC;AAWD,oDAqCC;AAED,8DAeC;AAED,0DA6BC;AA1HD,uCAAyB;AACzB,2CAA6B;AAI7B,mDAA6D;AAC7D,2CAA+C;AAE/C,qDAAgD;AAChD,iCAAmC;AAM5B,KAAK,UAAU,2BAA2B,CAC/C,MAAc,EACd,MAAc,EACd,QAA2B;IAE3B,OAAO,CACL,CAAC,CAAC,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,SAAS,KAAK,gBAAS,CAAC,MAAM;QACrC,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,uBAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC,CAAC;QACrE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAgB,EAAC,CAAC,CAAC,CAAC,CAClD,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,MAAc,EACd,MAAc,EACd,QAA2B;IAE3B,IAAI,CAAC,CAAC,MAAM,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAAE,OAAO;IAE3E,MAAM,CAAC,IAAI,CACT,iGAAiG,CAClG,CAAC;IAEF,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CACnC,MAAM,CAAC,UAAU,EACjB,0CAA0C,CAC3C,CAAC;IACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,kDAAkD,gBAAgB,EAAE,CACrE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,MAAM,sB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,IAAI,CAAC,CAAC,MAAM,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;QACzD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAEjE,mFAAmF;IACnF,4DAA4D;IAC5D,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,6BAAY,CAAC,sBAAsB,CAAC,CAAC,EAAE,CAAC;QACzE,iFAAiF;QACjF,kFAAkF;QAClF,sDAAsD;QACtD,iFAAiF;QACjF,gCAAgC;QAChC,MAAM,aAAa,GACjB,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;QACzD,gBAAgB,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,IAAI,CAC/C,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,EACnC,OAAO,EACP,gBAAgB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EACvC,aAAa,CACd,CAAC;IACJ,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
||||
6
lib/tracer-config.test.js
generated
6
lib/tracer-config.test.js
generated
@@ -46,7 +46,7 @@ function getTestConfig(tempDir) {
|
||||
const config = getTestConfig(tmpDir);
|
||||
// No traced languages
|
||||
config.languages = [languages_1.Language.javascript, languages_1.Language.python];
|
||||
t.deepEqual(await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0"), config, (0, testing_utils_1.createFeatures)([])), undefined);
|
||||
t.deepEqual(await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0"), config), undefined);
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("getCombinedTracerConfig - with start-tracing.json environment file", async (t) => {
|
||||
@@ -67,7 +67,7 @@ function getTestConfig(tempDir) {
|
||||
fs.mkdirSync(tracingEnvironmentDir, { recursive: true });
|
||||
const startTracingJson = path.join(tracingEnvironmentDir, "start-tracing.json");
|
||||
fs.writeFileSync(startTracingJson, JSON.stringify(startTracingEnv));
|
||||
const result = await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0"), config, (0, testing_utils_1.createFeatures)([]));
|
||||
const result = await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0"), config);
|
||||
t.notDeepEqual(result, undefined);
|
||||
const expectedEnv = startTracingEnv;
|
||||
if (process.platform === "win32") {
|
||||
@@ -102,7 +102,7 @@ function getTestConfig(tempDir) {
|
||||
fs.mkdirSync(tracingEnvironmentDir, { recursive: true });
|
||||
const startTracingJson = path.join(tracingEnvironmentDir, "start-tracing.json");
|
||||
fs.writeFileSync(startTracingJson, JSON.stringify(startTracingEnv));
|
||||
const result = await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0", { setsCodeqlRunnerEnvVar: true }), config, (0, testing_utils_1.createFeatures)([]));
|
||||
const result = await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0", { setsCodeqlRunnerEnvVar: true }), config);
|
||||
t.notDeepEqual(result, undefined);
|
||||
t.false(Object.prototype.hasOwnProperty.call(result?.env, "CODEQL_RUNNER"));
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"tracer-config.test.js","sourceRoot":"","sources":["../src/tracer-config.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,8CAAuB;AAGvB,2CAAuC;AACvC,mDAKyB;AACzB,mDAA0D;AAC1D,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,IAAA,gCAAgB,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uCAAuB,EAC1C,IAAA,iCAAiB,EAAC,OAAO,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC,EAC5D,MAAM,CACP,CAAC;QACF,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAElC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||
3
lib/trap-caching.js
generated
3
lib/trap-caching.js
generated
@@ -33,6 +33,7 @@ const path = __importStar(require("path"));
|
||||
const actionsCache = __importStar(require("@actions/cache"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const apiClient = __importStar(require("./api-client"));
|
||||
const doc_url_1 = require("./doc-url");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const util_1 = require("./util");
|
||||
// This constant should be bumped if we make a breaking change
|
||||
@@ -177,7 +178,7 @@ async function cleanupTrapCaches(config, features, logger) {
|
||||
if ((0, util_1.isHTTPError)(e) && e.status === 403) {
|
||||
logger.warning("Could not cleanup TRAP caches as the token did not have the required permissions. " +
|
||||
'To clean up TRAP caches, ensure the token has the "actions:write" permission. ' +
|
||||
"For more information, see https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs");
|
||||
`See ${doc_url_1.DocUrl.ASSIGNING_PERMISSIONS_TO_JOBS} for more information.`);
|
||||
}
|
||||
else {
|
||||
logger.info(`Failed to cleanup TRAP caches, continuing. Details: ${e}`);
|
||||
|
||||
File diff suppressed because one or more lines are too long
30
lib/upload-lib.js
generated
30
lib/upload-lib.js
generated
@@ -30,9 +30,9 @@ exports.InvalidSarifUploadError = void 0;
|
||||
exports.shouldShowCombineSarifFilesDeprecationWarning = shouldShowCombineSarifFilesDeprecationWarning;
|
||||
exports.populateRunAutomationDetails = populateRunAutomationDetails;
|
||||
exports.findSarifFilesInDir = findSarifFilesInDir;
|
||||
exports.uploadFromActions = uploadFromActions;
|
||||
exports.validateSarifFileSchema = validateSarifFileSchema;
|
||||
exports.buildPayload = buildPayload;
|
||||
exports.uploadFiles = uploadFiles;
|
||||
exports.waitForProcessing = waitForProcessing;
|
||||
exports.validateUniqueCategory = validateUniqueCategory;
|
||||
const fs = __importStar(require("fs"));
|
||||
@@ -49,7 +49,6 @@ const api_client_1 = require("./api-client");
|
||||
const codeql_1 = require("./codeql");
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const environment_1 = require("./environment");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const fingerprints = __importStar(require("./fingerprints"));
|
||||
const init_1 = require("./init");
|
||||
const repository_1 = require("./repository");
|
||||
@@ -278,13 +277,6 @@ function findSarifFilesInDir(sarifPath) {
|
||||
walkSarifFiles(sarifPath);
|
||||
return sarifFiles;
|
||||
}
|
||||
/**
|
||||
* Uploads a single SARIF file or a directory of SARIF files depending on what `sarifPath` refers
|
||||
* to.
|
||||
*/
|
||||
async function uploadFromActions(sarifPath, checkoutPath, category, logger) {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(checkoutPath), await actionsUtil.getRef(), await api.getAnalysisKey(), category, util.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getWorkflowRunAttempt(), checkoutPath, actionsUtil.getRequiredInput("matrix"), logger);
|
||||
}
|
||||
function getSarifFilePaths(sarifPath) {
|
||||
if (!fs.existsSync(sarifPath)) {
|
||||
// This is always a configuration error, even for first-party runs.
|
||||
@@ -389,19 +381,23 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
|
||||
}
|
||||
return payloadObj;
|
||||
}
|
||||
// Uploads the given set of sarif files.
|
||||
// Returns true iff the upload occurred and succeeded
|
||||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, workflowRunAttempt, sourceRoot, environment, logger) {
|
||||
/**
|
||||
* Uploads a single SARIF file or a directory of SARIF files depending on what `sarifPath` refers
|
||||
* to.
|
||||
*/
|
||||
async function uploadFiles(sarifPath, checkoutPath, category, features, logger) {
|
||||
const sarifFiles = getSarifFilePaths(sarifPath);
|
||||
logger.startGroup("Uploading results");
|
||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, actionsUtil.getTemporaryDirectory(), logger);
|
||||
// Validate that the files we were asked to upload are all valid SARIF files
|
||||
for (const file of sarifFiles) {
|
||||
validateSarifFileSchema(file, logger);
|
||||
}
|
||||
let sarif = await combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger);
|
||||
sarif = await fingerprints.addFingerprints(sarif, sourceRoot, logger);
|
||||
sarif = await fingerprints.addFingerprints(sarif, checkoutPath, logger);
|
||||
const analysisKey = await api.getAnalysisKey();
|
||||
const environment = actionsUtil.getRequiredInput("matrix");
|
||||
sarif = populateRunAutomationDetails(sarif, category, analysisKey, environment);
|
||||
const toolNames = util.getToolNames(sarif);
|
||||
logger.debug(`Validating that each SARIF run has a unique category`);
|
||||
@@ -410,8 +406,8 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
||||
const sarifPayload = JSON.stringify(sarif);
|
||||
logger.debug(`Compressing serialized SARIF`);
|
||||
const zippedSarif = zlib_1.default.gzipSync(sarifPayload).toString("base64");
|
||||
const checkoutURI = (0, file_url_1.default)(sourceRoot);
|
||||
const payload = buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, workflowRunID, workflowRunAttempt, checkoutURI, environment, toolNames, await actionsUtil.determineMergeBaseCommitOid());
|
||||
const checkoutURI = (0, file_url_1.default)(checkoutPath);
|
||||
const payload = buildPayload(await actionsUtil.getCommitOid(checkoutPath), await actionsUtil.getRef(), analysisKey, util.getRequiredEnvParam("GITHUB_WORKFLOW"), zippedSarif, actionsUtil.getWorkflowRunID(), actionsUtil.getWorkflowRunAttempt(), checkoutURI, environment, toolNames, await actionsUtil.determineMergeBaseCommitOid());
|
||||
// Log some useful debug info about the info
|
||||
const rawUploadSizeBytes = sarifPayload.length;
|
||||
logger.debug(`Raw upload size: ${rawUploadSizeBytes} bytes`);
|
||||
@@ -420,7 +416,7 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
||||
const numResultInSarif = countResultsInSarif(sarifPayload);
|
||||
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
||||
// Make the upload
|
||||
const sarifID = await uploadPayload(payload, repositoryNwo, logger);
|
||||
const sarifID = await uploadPayload(payload, (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), logger);
|
||||
logger.endGroup();
|
||||
return {
|
||||
statusReport: {
|
||||
|
||||
File diff suppressed because one or more lines are too long
5
lib/upload-sarif-action.js
generated
5
lib/upload-sarif-action.js
generated
@@ -27,6 +27,7 @@ const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
const status_report_1 = require("./status-report");
|
||||
@@ -48,12 +49,14 @@ async function run() {
|
||||
(0, util_1.initializeEnvironment)((0, actions_util_1.getActionVersion)());
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||
(0, util_1.checkActionVersion)((0, actions_util_1.getActionVersion)(), gitHubVersion);
|
||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), logger);
|
||||
const startingStatusReportBase = await (0, status_report_1.createStatusReportBase)(status_report_1.ActionName.UploadSarif, "starting", startedAt, undefined, await (0, util_1.checkDiskUsage)(), logger);
|
||||
if (startingStatusReportBase !== undefined) {
|
||||
await (0, status_report_1.sendStatusReport)(startingStatusReportBase);
|
||||
}
|
||||
try {
|
||||
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), logger);
|
||||
const uploadResult = await upload_lib.uploadFiles(actionsUtil.getRequiredInput("sarif_file"), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), features, logger);
|
||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||
// We don't upload results in test mode, so don't wait for processing
|
||||
if ((0, util_1.isInTestMode)()) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAAkD;AAClD,6CAAgD;AAChD,uCAAqD;AACrD,6CAAkD;AAClD,mDAOyB;AACzB,yDAA2C;AAC3C,iCAQgB;AAMhB,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C,EAC1C,MAAc;IAEd,MAAM,gBAAgB,GAAG,MAAM,IAAA,sCAAsB,EACnD,0BAAU,CAAC,WAAW,EACtB,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,IAAA,qBAAc,GAAE,EACtB,MAAM,CACP,CAAC;IACF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,YAAY,GAA4B;YAC5C,GAAG,gBAAgB;YACnB,GAAG,WAAW;SACf,CAAC;QACF,MAAM,IAAA,gCAAgB,EAAC,YAAY,CAAC,CAAC;IACvC,CAAC;AACH,CAAC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IAAA,sCAAsB,EACxD,0BAAU,CAAC,WAAW,EACtB,IAAA,gCAAgB,EAAC,KAAK,CAAC,EACvB,SAAS,EACT,SAAS,EACT,MAAM,IAAA,qBAAc,GAAE,EACtB,MAAM,EACN,OAAO,EACP,KAAK,CAAC,KAAK,CACZ,CAAC;QACF,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,IAAA,gCAAgB,EAAC,qBAAqB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO;IACT,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,sCAAsC,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CACjE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
1914
node_modules/.package-lock.json
generated
vendored
1914
node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
201
node_modules/@eslint/compat/LICENSE
generated
vendored
Normal file
201
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
node_modules/@eslint/compat/README.md
generated
vendored
Normal file
207
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
node_modules/@eslint/compat/dist/cjs/index.cjs
generated
vendored
Normal file
351
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
node_modules/@eslint/compat/dist/cjs/index.d.cts
generated
vendored
Normal file
45
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
node_modules/@eslint/compat/dist/esm/index.d.ts
generated
vendored
Normal file
45
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
node_modules/@eslint/compat/dist/esm/index.js
generated
vendored
Normal file
346
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
node_modules/@eslint/compat/package.json
generated
vendored
Normal file
61
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"
|
||||
}
|
||||
}
|
||||
19
node_modules/@eslint/eslintrc/README.md
generated
vendored
19
node_modules/@eslint/eslintrc/README.md
generated
vendored
@@ -33,8 +33,8 @@ const __dirname = path.dirname(__filename);
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname, // optional; default: process.cwd()
|
||||
resolvePluginsRelativeTo: __dirname, // optional
|
||||
recommendedConfig: js.configs.recommended, // optional
|
||||
allConfig: js.configs.all, // optional
|
||||
recommendedConfig: js.configs.recommended, // optional unless you're using "eslint:recommended"
|
||||
allConfig: js.configs.all, // optional unless you're using "eslint:all"
|
||||
});
|
||||
|
||||
export default [
|
||||
@@ -77,8 +77,8 @@ const js = require("@eslint/js");
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname, // optional; default: process.cwd()
|
||||
resolvePluginsRelativeTo: __dirname, // optional
|
||||
recommendedConfig: js.configs.recommended, // optional
|
||||
allConfig: js.configs.all, // optional
|
||||
recommendedConfig: js.configs.recommended, // optional unless using "eslint:recommended"
|
||||
allConfig: js.configs.all, // optional unless using "eslint:all"
|
||||
});
|
||||
|
||||
module.exports = [
|
||||
@@ -110,6 +110,17 @@ module.exports = [
|
||||
];
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**TypeError: Missing parameter 'recommendedConfig' in FlatCompat constructor**
|
||||
|
||||
The `recommendedConfig` option is required when any config uses `eslint:recommended`, including any config in an `extends` clause. To fix this, follow the example above using `@eslint/js` to provide the `eslint:recommended` config.
|
||||
|
||||
**TypeError: Missing parameter 'allConfig' in FlatCompat constructor**
|
||||
|
||||
The `allConfig` option is required when any config uses `eslint:all`, including any config in an `extends` clause. To fix this, follow the example above using `@eslint/js` to provide the `eslint:all` config.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
|
||||
75
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs
generated
vendored
75
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs
generated
vendored
@@ -697,6 +697,13 @@ const severityMap = {
|
||||
|
||||
const validated = new WeakSet();
|
||||
|
||||
// JSON schema that disallows passing any options
|
||||
const noOptionsSchema = Object.freeze({
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
});
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -708,17 +715,36 @@ class ConfigValidator {
|
||||
|
||||
/**
|
||||
* Gets a complete options schema for a rule.
|
||||
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
||||
* @returns {Object} JSON Schema for the rule's options.
|
||||
* @param {Rule} rule A rule object
|
||||
* @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
|
||||
* @returns {Object|null} JSON Schema for the rule's options.
|
||||
* `null` if rule wasn't passed or its `meta.schema` is `false`.
|
||||
*/
|
||||
getRuleOptionsSchema(rule) {
|
||||
if (!rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const schema = rule.schema || rule.meta && rule.meta.schema;
|
||||
if (!rule.meta) {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// Given a tuple of schemas, insert warning level at the beginning
|
||||
const schema = rule.meta.schema;
|
||||
|
||||
if (typeof schema === "undefined") {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// `schema:false` is an allowed explicit opt-out of options validation for the rule
|
||||
if (schema === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof schema !== "object" || schema === null) {
|
||||
throw new TypeError("Rule's `meta.schema` must be an array or object");
|
||||
}
|
||||
|
||||
// ESLint-specific array form needs to be converted into a valid JSON Schema definition
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length) {
|
||||
return {
|
||||
@@ -728,16 +754,13 @@ class ConfigValidator {
|
||||
maxItems: schema.length
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
};
|
||||
|
||||
// `schema:[]` is an explicit way to specify that the rule does not accept any options
|
||||
return { ...noOptionsSchema };
|
||||
}
|
||||
|
||||
// Given a full schema, leave it alone
|
||||
return schema || null;
|
||||
// `schema:<object>` is assumed to be a valid JSON Schema definition
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -765,10 +788,18 @@ class ConfigValidator {
|
||||
*/
|
||||
validateRuleSchema(rule, localOptions) {
|
||||
if (!ruleValidators.has(rule)) {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
try {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
} catch (err) {
|
||||
const errorWithCode = new Error(err.message, { cause: err });
|
||||
|
||||
errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA";
|
||||
|
||||
throw errorWithCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,13 +832,21 @@ class ConfigValidator {
|
||||
this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
||||
}
|
||||
} catch (err) {
|
||||
const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
|
||||
? `Error while processing options validation schema of rule '${ruleId}': ${err.message}`
|
||||
: `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
|
||||
if (typeof source === "string") {
|
||||
throw new Error(`${source}:\n\t${enhancedMessage}`);
|
||||
} else {
|
||||
throw new Error(enhancedMessage);
|
||||
enhancedMessage = `${source}:\n\t${enhancedMessage}`;
|
||||
}
|
||||
|
||||
const enhancedError = new Error(enhancedMessage, { cause: err });
|
||||
|
||||
if (err.code) {
|
||||
enhancedError.code = err.code;
|
||||
}
|
||||
|
||||
throw enhancedError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map
generated
vendored
2
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
95
node_modules/@eslint/eslintrc/dist/eslintrc.cjs
generated
vendored
95
node_modules/@eslint/eslintrc/dist/eslintrc.cjs
generated
vendored
@@ -716,31 +716,18 @@ function createConfig(instance, indices) {
|
||||
* @param {string} pluginId The plugin ID for prefix.
|
||||
* @param {Record<string,T>} defs The definitions to collect.
|
||||
* @param {Map<string, U>} map The map to output.
|
||||
* @param {function(T): U} [normalize] The normalize function for each value.
|
||||
* @returns {void}
|
||||
*/
|
||||
function collect(pluginId, defs, map, normalize) {
|
||||
function collect(pluginId, defs, map) {
|
||||
if (defs) {
|
||||
const prefix = pluginId && `${pluginId}/`;
|
||||
|
||||
for (const [key, value] of Object.entries(defs)) {
|
||||
map.set(
|
||||
`${prefix}${key}`,
|
||||
normalize ? normalize(value) : value
|
||||
);
|
||||
map.set(`${prefix}${key}`, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a rule definition.
|
||||
* @param {Function|Rule} rule The rule definition to normalize.
|
||||
* @returns {Rule} The normalized rule definition.
|
||||
*/
|
||||
function normalizePluginRule(rule) {
|
||||
return typeof rule === "function" ? { create: rule } : rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the mutation methods from a given map.
|
||||
* @param {Map<any, any>} map The map object to delete.
|
||||
@@ -782,7 +769,7 @@ function initPluginMemberMaps(elements, slots) {
|
||||
|
||||
collect(pluginId, plugin.environments, slots.envMap);
|
||||
collect(pluginId, plugin.processors, slots.processorMap);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap, normalizePluginRule);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1938,6 +1925,13 @@ const severityMap = {
|
||||
|
||||
const validated = new WeakSet();
|
||||
|
||||
// JSON schema that disallows passing any options
|
||||
const noOptionsSchema = Object.freeze({
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
});
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1949,17 +1943,36 @@ class ConfigValidator {
|
||||
|
||||
/**
|
||||
* Gets a complete options schema for a rule.
|
||||
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
||||
* @returns {Object} JSON Schema for the rule's options.
|
||||
* @param {Rule} rule A rule object
|
||||
* @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
|
||||
* @returns {Object|null} JSON Schema for the rule's options.
|
||||
* `null` if rule wasn't passed or its `meta.schema` is `false`.
|
||||
*/
|
||||
getRuleOptionsSchema(rule) {
|
||||
if (!rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const schema = rule.schema || rule.meta && rule.meta.schema;
|
||||
if (!rule.meta) {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// Given a tuple of schemas, insert warning level at the beginning
|
||||
const schema = rule.meta.schema;
|
||||
|
||||
if (typeof schema === "undefined") {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// `schema:false` is an allowed explicit opt-out of options validation for the rule
|
||||
if (schema === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof schema !== "object" || schema === null) {
|
||||
throw new TypeError("Rule's `meta.schema` must be an array or object");
|
||||
}
|
||||
|
||||
// ESLint-specific array form needs to be converted into a valid JSON Schema definition
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length) {
|
||||
return {
|
||||
@@ -1969,16 +1982,13 @@ class ConfigValidator {
|
||||
maxItems: schema.length
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
};
|
||||
|
||||
// `schema:[]` is an explicit way to specify that the rule does not accept any options
|
||||
return { ...noOptionsSchema };
|
||||
}
|
||||
|
||||
// Given a full schema, leave it alone
|
||||
return schema || null;
|
||||
// `schema:<object>` is assumed to be a valid JSON Schema definition
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2006,10 +2016,18 @@ class ConfigValidator {
|
||||
*/
|
||||
validateRuleSchema(rule, localOptions) {
|
||||
if (!ruleValidators.has(rule)) {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
try {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
} catch (err) {
|
||||
const errorWithCode = new Error(err.message, { cause: err });
|
||||
|
||||
errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA";
|
||||
|
||||
throw errorWithCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2042,13 +2060,21 @@ class ConfigValidator {
|
||||
this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
||||
}
|
||||
} catch (err) {
|
||||
const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
|
||||
? `Error while processing options validation schema of rule '${ruleId}': ${err.message}`
|
||||
: `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
|
||||
if (typeof source === "string") {
|
||||
throw new Error(`${source}:\n\t${enhancedMessage}`);
|
||||
} else {
|
||||
throw new Error(enhancedMessage);
|
||||
enhancedMessage = `${source}:\n\t${enhancedMessage}`;
|
||||
}
|
||||
|
||||
const enhancedError = new Error(enhancedMessage, { cause: err });
|
||||
|
||||
if (err.code) {
|
||||
enhancedError.code = err.code;
|
||||
}
|
||||
|
||||
throw enhancedError;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4331,6 +4357,7 @@ const Legacy = {
|
||||
OverrideTester,
|
||||
getUsedExtractedConfigs,
|
||||
environments,
|
||||
loadConfigFile,
|
||||
|
||||
// shared
|
||||
ConfigOps,
|
||||
|
||||
2
node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map
generated
vendored
2
node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
6
node_modules/@eslint/eslintrc/lib/config-array-factory.js
generated
vendored
6
node_modules/@eslint/eslintrc/lib/config-array-factory.js
generated
vendored
@@ -1148,4 +1148,8 @@ class ConfigArrayFactory {
|
||||
}
|
||||
}
|
||||
|
||||
export { ConfigArrayFactory, createContext };
|
||||
export {
|
||||
ConfigArrayFactory,
|
||||
createContext,
|
||||
loadConfigFile
|
||||
};
|
||||
|
||||
19
node_modules/@eslint/eslintrc/lib/config-array/config-array.js
generated
vendored
19
node_modules/@eslint/eslintrc/lib/config-array/config-array.js
generated
vendored
@@ -319,31 +319,18 @@ function createConfig(instance, indices) {
|
||||
* @param {string} pluginId The plugin ID for prefix.
|
||||
* @param {Record<string,T>} defs The definitions to collect.
|
||||
* @param {Map<string, U>} map The map to output.
|
||||
* @param {function(T): U} [normalize] The normalize function for each value.
|
||||
* @returns {void}
|
||||
*/
|
||||
function collect(pluginId, defs, map, normalize) {
|
||||
function collect(pluginId, defs, map) {
|
||||
if (defs) {
|
||||
const prefix = pluginId && `${pluginId}/`;
|
||||
|
||||
for (const [key, value] of Object.entries(defs)) {
|
||||
map.set(
|
||||
`${prefix}${key}`,
|
||||
normalize ? normalize(value) : value
|
||||
);
|
||||
map.set(`${prefix}${key}`, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a rule definition.
|
||||
* @param {Function|Rule} rule The rule definition to normalize.
|
||||
* @returns {Rule} The normalized rule definition.
|
||||
*/
|
||||
function normalizePluginRule(rule) {
|
||||
return typeof rule === "function" ? { create: rule } : rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the mutation methods from a given map.
|
||||
* @param {Map<any, any>} map The map object to delete.
|
||||
@@ -385,7 +372,7 @@ function initPluginMemberMaps(elements, slots) {
|
||||
|
||||
collect(pluginId, plugin.environments, slots.envMap);
|
||||
collect(pluginId, plugin.processors, slots.processorMap);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap, normalizePluginRule);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
4
node_modules/@eslint/eslintrc/lib/index.js
generated
vendored
4
node_modules/@eslint/eslintrc/lib/index.js
generated
vendored
@@ -8,7 +8,8 @@
|
||||
|
||||
import {
|
||||
ConfigArrayFactory,
|
||||
createContext as createConfigArrayFactoryContext
|
||||
createContext as createConfigArrayFactoryContext,
|
||||
loadConfigFile
|
||||
} from "./config-array-factory.js";
|
||||
|
||||
import { CascadingConfigArrayFactory } from "./cascading-config-array-factory.js";
|
||||
@@ -39,6 +40,7 @@ const Legacy = {
|
||||
OverrideTester,
|
||||
getUsedExtractedConfigs,
|
||||
environments,
|
||||
loadConfigFile,
|
||||
|
||||
// shared
|
||||
ConfigOps,
|
||||
|
||||
81
node_modules/@eslint/eslintrc/lib/shared/config-validator.js
generated
vendored
81
node_modules/@eslint/eslintrc/lib/shared/config-validator.js
generated
vendored
@@ -5,6 +5,12 @@
|
||||
|
||||
/* eslint class-methods-use-this: "off" */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Typedefs
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("../shared/types").Rule} Rule */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -33,6 +39,13 @@ const severityMap = {
|
||||
|
||||
const validated = new WeakSet();
|
||||
|
||||
// JSON schema that disallows passing any options
|
||||
const noOptionsSchema = Object.freeze({
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
});
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -44,17 +57,36 @@ export default class ConfigValidator {
|
||||
|
||||
/**
|
||||
* Gets a complete options schema for a rule.
|
||||
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
||||
* @returns {Object} JSON Schema for the rule's options.
|
||||
* @param {Rule} rule A rule object
|
||||
* @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
|
||||
* @returns {Object|null} JSON Schema for the rule's options.
|
||||
* `null` if rule wasn't passed or its `meta.schema` is `false`.
|
||||
*/
|
||||
getRuleOptionsSchema(rule) {
|
||||
if (!rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const schema = rule.schema || rule.meta && rule.meta.schema;
|
||||
if (!rule.meta) {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// Given a tuple of schemas, insert warning level at the beginning
|
||||
const schema = rule.meta.schema;
|
||||
|
||||
if (typeof schema === "undefined") {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// `schema:false` is an allowed explicit opt-out of options validation for the rule
|
||||
if (schema === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof schema !== "object" || schema === null) {
|
||||
throw new TypeError("Rule's `meta.schema` must be an array or object");
|
||||
}
|
||||
|
||||
// ESLint-specific array form needs to be converted into a valid JSON Schema definition
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length) {
|
||||
return {
|
||||
@@ -64,16 +96,13 @@ export default class ConfigValidator {
|
||||
maxItems: schema.length
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
};
|
||||
|
||||
// `schema:[]` is an explicit way to specify that the rule does not accept any options
|
||||
return { ...noOptionsSchema };
|
||||
}
|
||||
|
||||
// Given a full schema, leave it alone
|
||||
return schema || null;
|
||||
// `schema:<object>` is assumed to be a valid JSON Schema definition
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,10 +130,18 @@ export default class ConfigValidator {
|
||||
*/
|
||||
validateRuleSchema(rule, localOptions) {
|
||||
if (!ruleValidators.has(rule)) {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
try {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
} catch (err) {
|
||||
const errorWithCode = new Error(err.message, { cause: err });
|
||||
|
||||
errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA";
|
||||
|
||||
throw errorWithCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,13 +174,21 @@ export default class ConfigValidator {
|
||||
this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
||||
}
|
||||
} catch (err) {
|
||||
const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
|
||||
? `Error while processing options validation schema of rule '${ruleId}': ${err.message}`
|
||||
: `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
|
||||
if (typeof source === "string") {
|
||||
throw new Error(`${source}:\n\t${enhancedMessage}`);
|
||||
} else {
|
||||
throw new Error(enhancedMessage);
|
||||
enhancedMessage = `${source}:\n\t${enhancedMessage}`;
|
||||
}
|
||||
|
||||
const enhancedError = new Error(enhancedMessage, { cause: err });
|
||||
|
||||
if (err.code) {
|
||||
enhancedError.code = err.code;
|
||||
}
|
||||
|
||||
throw enhancedError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
201
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/LICENSE
generated
vendored
Normal file
201
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/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 contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
105
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/README.md
generated
vendored
Normal file
105
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/README.md
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
# eslint-visitor-keys
|
||||
|
||||
[](https://www.npmjs.com/package/eslint-visitor-keys)
|
||||
[](http://www.npmtrends.com/eslint-visitor-keys)
|
||||
[](https://github.com/eslint/eslint-visitor-keys/actions)
|
||||
|
||||
Constants and utilities about visitor keys to traverse AST.
|
||||
|
||||
## 💿 Installation
|
||||
|
||||
Use [npm] to install.
|
||||
|
||||
```bash
|
||||
$ npm install eslint-visitor-keys
|
||||
```
|
||||
|
||||
### Requirements
|
||||
|
||||
- [Node.js] `^18.18.0`, `^20.9.0`, or `>=21.1.0`
|
||||
|
||||
|
||||
## 📖 Usage
|
||||
|
||||
To use in an ESM file:
|
||||
|
||||
```js
|
||||
import * as evk from "eslint-visitor-keys"
|
||||
```
|
||||
|
||||
To use in a CommonJS file:
|
||||
|
||||
```js
|
||||
const evk = require("eslint-visitor-keys")
|
||||
```
|
||||
|
||||
### evk.KEYS
|
||||
|
||||
> type: `{ [type: string]: string[] | undefined }`
|
||||
|
||||
Visitor keys. This keys are frozen.
|
||||
|
||||
This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
|
||||
```
|
||||
|
||||
### evk.getKeys(node)
|
||||
|
||||
> type: `(node: object) => string[]`
|
||||
|
||||
Get the visitor keys of a given AST node.
|
||||
|
||||
This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
|
||||
|
||||
This will be used to traverse unknown nodes.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
const node = {
|
||||
type: "AssignmentExpression",
|
||||
left: { type: "Identifier", name: "foo" },
|
||||
right: { type: "Literal", value: 0 }
|
||||
}
|
||||
console.log(evk.getKeys(node)) // → ["type", "left", "right"]
|
||||
```
|
||||
|
||||
### evk.unionWith(additionalKeys)
|
||||
|
||||
> type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
|
||||
|
||||
Make the union set with `evk.KEYS` and the given keys.
|
||||
|
||||
- The order of keys is, `additionalKeys` is at first, then `evk.KEYS` is concatenated after that.
|
||||
- It removes duplicated keys as keeping the first one.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
console.log(evk.unionWith({
|
||||
MethodDefinition: ["decorators"]
|
||||
})) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
|
||||
```
|
||||
|
||||
## 📰 Change log
|
||||
|
||||
See [GitHub releases](https://github.com/eslint/eslint-visitor-keys/releases).
|
||||
|
||||
## 🍻 Contributing
|
||||
|
||||
Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
|
||||
|
||||
### Development commands
|
||||
|
||||
- `npm test` runs tests and measures code coverage.
|
||||
- `npm run lint` checks source codes with ESLint.
|
||||
- `npm run test:open-coverage` opens the code coverage report of the previous test with your default browser.
|
||||
|
||||
|
||||
[npm]: https://www.npmjs.com/
|
||||
[Node.js]: https://nodejs.org/
|
||||
[ESTree]: https://github.com/estree/estree
|
||||
384
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs
generated
vendored
Normal file
384
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs
generated
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
const KEYS = {
|
||||
ArrayExpression: [
|
||||
"elements"
|
||||
],
|
||||
ArrayPattern: [
|
||||
"elements"
|
||||
],
|
||||
ArrowFunctionExpression: [
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
AssignmentExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AssignmentPattern: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AwaitExpression: [
|
||||
"argument"
|
||||
],
|
||||
BinaryExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
BlockStatement: [
|
||||
"body"
|
||||
],
|
||||
BreakStatement: [
|
||||
"label"
|
||||
],
|
||||
CallExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
CatchClause: [
|
||||
"param",
|
||||
"body"
|
||||
],
|
||||
ChainExpression: [
|
||||
"expression"
|
||||
],
|
||||
ClassBody: [
|
||||
"body"
|
||||
],
|
||||
ClassDeclaration: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ClassExpression: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ConditionalExpression: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ContinueStatement: [
|
||||
"label"
|
||||
],
|
||||
DebuggerStatement: [],
|
||||
DoWhileStatement: [
|
||||
"body",
|
||||
"test"
|
||||
],
|
||||
EmptyStatement: [],
|
||||
ExperimentalRestProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExperimentalSpreadProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExportAllDeclaration: [
|
||||
"exported",
|
||||
"source"
|
||||
],
|
||||
ExportDefaultDeclaration: [
|
||||
"declaration"
|
||||
],
|
||||
ExportNamedDeclaration: [
|
||||
"declaration",
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ExportSpecifier: [
|
||||
"exported",
|
||||
"local"
|
||||
],
|
||||
ExpressionStatement: [
|
||||
"expression"
|
||||
],
|
||||
ForInStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForOfStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForStatement: [
|
||||
"init",
|
||||
"test",
|
||||
"update",
|
||||
"body"
|
||||
],
|
||||
FunctionDeclaration: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
FunctionExpression: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
Identifier: [],
|
||||
IfStatement: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ImportDeclaration: [
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ImportDefaultSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportExpression: [
|
||||
"source"
|
||||
],
|
||||
ImportNamespaceSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportSpecifier: [
|
||||
"imported",
|
||||
"local"
|
||||
],
|
||||
JSXAttribute: [
|
||||
"name",
|
||||
"value"
|
||||
],
|
||||
JSXClosingElement: [
|
||||
"name"
|
||||
],
|
||||
JSXClosingFragment: [],
|
||||
JSXElement: [
|
||||
"openingElement",
|
||||
"children",
|
||||
"closingElement"
|
||||
],
|
||||
JSXEmptyExpression: [],
|
||||
JSXExpressionContainer: [
|
||||
"expression"
|
||||
],
|
||||
JSXFragment: [
|
||||
"openingFragment",
|
||||
"children",
|
||||
"closingFragment"
|
||||
],
|
||||
JSXIdentifier: [],
|
||||
JSXMemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
JSXNamespacedName: [
|
||||
"namespace",
|
||||
"name"
|
||||
],
|
||||
JSXOpeningElement: [
|
||||
"name",
|
||||
"attributes"
|
||||
],
|
||||
JSXOpeningFragment: [],
|
||||
JSXSpreadAttribute: [
|
||||
"argument"
|
||||
],
|
||||
JSXSpreadChild: [
|
||||
"expression"
|
||||
],
|
||||
JSXText: [],
|
||||
LabeledStatement: [
|
||||
"label",
|
||||
"body"
|
||||
],
|
||||
Literal: [],
|
||||
LogicalExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
MemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
MetaProperty: [
|
||||
"meta",
|
||||
"property"
|
||||
],
|
||||
MethodDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
NewExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
ObjectExpression: [
|
||||
"properties"
|
||||
],
|
||||
ObjectPattern: [
|
||||
"properties"
|
||||
],
|
||||
PrivateIdentifier: [],
|
||||
Program: [
|
||||
"body"
|
||||
],
|
||||
Property: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
PropertyDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
RestElement: [
|
||||
"argument"
|
||||
],
|
||||
ReturnStatement: [
|
||||
"argument"
|
||||
],
|
||||
SequenceExpression: [
|
||||
"expressions"
|
||||
],
|
||||
SpreadElement: [
|
||||
"argument"
|
||||
],
|
||||
StaticBlock: [
|
||||
"body"
|
||||
],
|
||||
Super: [],
|
||||
SwitchCase: [
|
||||
"test",
|
||||
"consequent"
|
||||
],
|
||||
SwitchStatement: [
|
||||
"discriminant",
|
||||
"cases"
|
||||
],
|
||||
TaggedTemplateExpression: [
|
||||
"tag",
|
||||
"quasi"
|
||||
],
|
||||
TemplateElement: [],
|
||||
TemplateLiteral: [
|
||||
"quasis",
|
||||
"expressions"
|
||||
],
|
||||
ThisExpression: [],
|
||||
ThrowStatement: [
|
||||
"argument"
|
||||
],
|
||||
TryStatement: [
|
||||
"block",
|
||||
"handler",
|
||||
"finalizer"
|
||||
],
|
||||
UnaryExpression: [
|
||||
"argument"
|
||||
],
|
||||
UpdateExpression: [
|
||||
"argument"
|
||||
],
|
||||
VariableDeclaration: [
|
||||
"declarations"
|
||||
],
|
||||
VariableDeclarator: [
|
||||
"id",
|
||||
"init"
|
||||
],
|
||||
WhileStatement: [
|
||||
"test",
|
||||
"body"
|
||||
],
|
||||
WithStatement: [
|
||||
"object",
|
||||
"body"
|
||||
],
|
||||
YieldExpression: [
|
||||
"argument"
|
||||
]
|
||||
};
|
||||
|
||||
// Types.
|
||||
const NODE_TYPES = Object.keys(KEYS);
|
||||
|
||||
// Freeze the keys.
|
||||
for (const type of NODE_TYPES) {
|
||||
Object.freeze(KEYS[type]);
|
||||
}
|
||||
Object.freeze(KEYS);
|
||||
|
||||
/**
|
||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
* See LICENSE file in root directory for full license.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
|
||||
*/
|
||||
|
||||
// List to ignore keys.
|
||||
const KEY_BLACKLIST = new Set([
|
||||
"parent",
|
||||
"leadingComments",
|
||||
"trailingComments"
|
||||
]);
|
||||
|
||||
/**
|
||||
* Check whether a given key should be used or not.
|
||||
* @param {string} key The key to check.
|
||||
* @returns {boolean} `true` if the key should be used.
|
||||
*/
|
||||
function filterKey(key) {
|
||||
return !KEY_BLACKLIST.has(key) && key[0] !== "_";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
function getKeys(node) {
|
||||
return Object.keys(node).filter(filterKey);
|
||||
}
|
||||
|
||||
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
|
||||
// eslint-disable-next-line valid-jsdoc
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
function unionWith(additionalKeys) {
|
||||
const retv = /** @type {{
|
||||
[type: string]: ReadonlyArray<string>
|
||||
}} */ (Object.assign({}, KEYS));
|
||||
|
||||
for (const type of Object.keys(additionalKeys)) {
|
||||
if (Object.prototype.hasOwnProperty.call(retv, type)) {
|
||||
const keys = new Set(additionalKeys[type]);
|
||||
|
||||
for (const key of retv[type]) {
|
||||
keys.add(key);
|
||||
}
|
||||
|
||||
retv[type] = Object.freeze(Array.from(keys));
|
||||
} else {
|
||||
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
||||
}
|
||||
}
|
||||
|
||||
return Object.freeze(retv);
|
||||
}
|
||||
|
||||
exports.KEYS = KEYS;
|
||||
exports.getKeys = getKeys;
|
||||
exports.unionWith = unionWith;
|
||||
27
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts
generated
vendored
Normal file
27
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
type VisitorKeys$1 = {
|
||||
readonly [type: string]: readonly string[];
|
||||
};
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
declare const KEYS: VisitorKeys$1;
|
||||
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
declare function getKeys(node: object): readonly string[];
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
|
||||
|
||||
type VisitorKeys = VisitorKeys$1;
|
||||
|
||||
export { KEYS, VisitorKeys, getKeys, unionWith };
|
||||
16
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/index.d.ts
generated
vendored
Normal file
16
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
export function getKeys(node: object): readonly string[];
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
export function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
|
||||
export { KEYS };
|
||||
export type VisitorKeys = import('./visitor-keys.js').VisitorKeys;
|
||||
import KEYS from "./visitor-keys.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
12
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts
generated
vendored
Normal file
12
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export default KEYS;
|
||||
export type VisitorKeys = {
|
||||
readonly [type: string]: readonly string[];
|
||||
};
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
declare const KEYS: VisitorKeys;
|
||||
//# sourceMappingURL=visitor-keys.d.ts.map
|
||||
65
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/lib/index.js
generated
vendored
Normal file
65
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
* See LICENSE file in root directory for full license.
|
||||
*/
|
||||
import KEYS from "./visitor-keys.js";
|
||||
|
||||
/**
|
||||
* @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
|
||||
*/
|
||||
|
||||
// List to ignore keys.
|
||||
const KEY_BLACKLIST = new Set([
|
||||
"parent",
|
||||
"leadingComments",
|
||||
"trailingComments"
|
||||
]);
|
||||
|
||||
/**
|
||||
* Check whether a given key should be used or not.
|
||||
* @param {string} key The key to check.
|
||||
* @returns {boolean} `true` if the key should be used.
|
||||
*/
|
||||
function filterKey(key) {
|
||||
return !KEY_BLACKLIST.has(key) && key[0] !== "_";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
export function getKeys(node) {
|
||||
return Object.keys(node).filter(filterKey);
|
||||
}
|
||||
|
||||
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
|
||||
// eslint-disable-next-line valid-jsdoc
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
export function unionWith(additionalKeys) {
|
||||
const retv = /** @type {{
|
||||
[type: string]: ReadonlyArray<string>
|
||||
}} */ (Object.assign({}, KEYS));
|
||||
|
||||
for (const type of Object.keys(additionalKeys)) {
|
||||
if (Object.prototype.hasOwnProperty.call(retv, type)) {
|
||||
const keys = new Set(additionalKeys[type]);
|
||||
|
||||
for (const key of retv[type]) {
|
||||
keys.add(key);
|
||||
}
|
||||
|
||||
retv[type] = Object.freeze(Array.from(keys));
|
||||
} else {
|
||||
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
||||
}
|
||||
}
|
||||
|
||||
return Object.freeze(retv);
|
||||
}
|
||||
|
||||
export { KEYS };
|
||||
315
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/lib/visitor-keys.js
generated
vendored
Normal file
315
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/lib/visitor-keys.js
generated
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
const KEYS = {
|
||||
ArrayExpression: [
|
||||
"elements"
|
||||
],
|
||||
ArrayPattern: [
|
||||
"elements"
|
||||
],
|
||||
ArrowFunctionExpression: [
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
AssignmentExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AssignmentPattern: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AwaitExpression: [
|
||||
"argument"
|
||||
],
|
||||
BinaryExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
BlockStatement: [
|
||||
"body"
|
||||
],
|
||||
BreakStatement: [
|
||||
"label"
|
||||
],
|
||||
CallExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
CatchClause: [
|
||||
"param",
|
||||
"body"
|
||||
],
|
||||
ChainExpression: [
|
||||
"expression"
|
||||
],
|
||||
ClassBody: [
|
||||
"body"
|
||||
],
|
||||
ClassDeclaration: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ClassExpression: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ConditionalExpression: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ContinueStatement: [
|
||||
"label"
|
||||
],
|
||||
DebuggerStatement: [],
|
||||
DoWhileStatement: [
|
||||
"body",
|
||||
"test"
|
||||
],
|
||||
EmptyStatement: [],
|
||||
ExperimentalRestProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExperimentalSpreadProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExportAllDeclaration: [
|
||||
"exported",
|
||||
"source"
|
||||
],
|
||||
ExportDefaultDeclaration: [
|
||||
"declaration"
|
||||
],
|
||||
ExportNamedDeclaration: [
|
||||
"declaration",
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ExportSpecifier: [
|
||||
"exported",
|
||||
"local"
|
||||
],
|
||||
ExpressionStatement: [
|
||||
"expression"
|
||||
],
|
||||
ForInStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForOfStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForStatement: [
|
||||
"init",
|
||||
"test",
|
||||
"update",
|
||||
"body"
|
||||
],
|
||||
FunctionDeclaration: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
FunctionExpression: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
Identifier: [],
|
||||
IfStatement: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ImportDeclaration: [
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ImportDefaultSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportExpression: [
|
||||
"source"
|
||||
],
|
||||
ImportNamespaceSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportSpecifier: [
|
||||
"imported",
|
||||
"local"
|
||||
],
|
||||
JSXAttribute: [
|
||||
"name",
|
||||
"value"
|
||||
],
|
||||
JSXClosingElement: [
|
||||
"name"
|
||||
],
|
||||
JSXClosingFragment: [],
|
||||
JSXElement: [
|
||||
"openingElement",
|
||||
"children",
|
||||
"closingElement"
|
||||
],
|
||||
JSXEmptyExpression: [],
|
||||
JSXExpressionContainer: [
|
||||
"expression"
|
||||
],
|
||||
JSXFragment: [
|
||||
"openingFragment",
|
||||
"children",
|
||||
"closingFragment"
|
||||
],
|
||||
JSXIdentifier: [],
|
||||
JSXMemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
JSXNamespacedName: [
|
||||
"namespace",
|
||||
"name"
|
||||
],
|
||||
JSXOpeningElement: [
|
||||
"name",
|
||||
"attributes"
|
||||
],
|
||||
JSXOpeningFragment: [],
|
||||
JSXSpreadAttribute: [
|
||||
"argument"
|
||||
],
|
||||
JSXSpreadChild: [
|
||||
"expression"
|
||||
],
|
||||
JSXText: [],
|
||||
LabeledStatement: [
|
||||
"label",
|
||||
"body"
|
||||
],
|
||||
Literal: [],
|
||||
LogicalExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
MemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
MetaProperty: [
|
||||
"meta",
|
||||
"property"
|
||||
],
|
||||
MethodDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
NewExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
ObjectExpression: [
|
||||
"properties"
|
||||
],
|
||||
ObjectPattern: [
|
||||
"properties"
|
||||
],
|
||||
PrivateIdentifier: [],
|
||||
Program: [
|
||||
"body"
|
||||
],
|
||||
Property: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
PropertyDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
RestElement: [
|
||||
"argument"
|
||||
],
|
||||
ReturnStatement: [
|
||||
"argument"
|
||||
],
|
||||
SequenceExpression: [
|
||||
"expressions"
|
||||
],
|
||||
SpreadElement: [
|
||||
"argument"
|
||||
],
|
||||
StaticBlock: [
|
||||
"body"
|
||||
],
|
||||
Super: [],
|
||||
SwitchCase: [
|
||||
"test",
|
||||
"consequent"
|
||||
],
|
||||
SwitchStatement: [
|
||||
"discriminant",
|
||||
"cases"
|
||||
],
|
||||
TaggedTemplateExpression: [
|
||||
"tag",
|
||||
"quasi"
|
||||
],
|
||||
TemplateElement: [],
|
||||
TemplateLiteral: [
|
||||
"quasis",
|
||||
"expressions"
|
||||
],
|
||||
ThisExpression: [],
|
||||
ThrowStatement: [
|
||||
"argument"
|
||||
],
|
||||
TryStatement: [
|
||||
"block",
|
||||
"handler",
|
||||
"finalizer"
|
||||
],
|
||||
UnaryExpression: [
|
||||
"argument"
|
||||
],
|
||||
UpdateExpression: [
|
||||
"argument"
|
||||
],
|
||||
VariableDeclaration: [
|
||||
"declarations"
|
||||
],
|
||||
VariableDeclarator: [
|
||||
"id",
|
||||
"init"
|
||||
],
|
||||
WhileStatement: [
|
||||
"test",
|
||||
"body"
|
||||
],
|
||||
WithStatement: [
|
||||
"object",
|
||||
"body"
|
||||
],
|
||||
YieldExpression: [
|
||||
"argument"
|
||||
]
|
||||
};
|
||||
|
||||
// Types.
|
||||
const NODE_TYPES = Object.keys(KEYS);
|
||||
|
||||
// Freeze the keys.
|
||||
for (const type of NODE_TYPES) {
|
||||
Object.freeze(KEYS[type]);
|
||||
}
|
||||
Object.freeze(KEYS);
|
||||
|
||||
export default KEYS;
|
||||
74
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/package.json
generated
vendored
Normal file
74
node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/package.json
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"name": "eslint-visitor-keys",
|
||||
"version": "4.0.0",
|
||||
"description": "Constants and utilities about visitor keys to traverse AST.",
|
||||
"type": "module",
|
||||
"main": "dist/eslint-visitor-keys.cjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": "./lib/index.js",
|
||||
"require": "./dist/eslint-visitor-keys.cjs"
|
||||
},
|
||||
"./dist/eslint-visitor-keys.cjs"
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist/index.d.ts",
|
||||
"dist/visitor-keys.d.ts",
|
||||
"dist/eslint-visitor-keys.cjs",
|
||||
"dist/eslint-visitor-keys.d.cts",
|
||||
"lib"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/estree": "^0.0.51",
|
||||
"@types/estree-jsx": "^0.0.1",
|
||||
"@typescript-eslint/parser": "^5.14.0",
|
||||
"c8": "^7.11.0",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^7.29.0",
|
||||
"eslint-config-eslint": "^7.0.0",
|
||||
"eslint-plugin-jsdoc": "^35.4.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-release": "^3.2.0",
|
||||
"esquery": "^1.4.0",
|
||||
"json-diff": "^0.7.3",
|
||||
"mocha": "^9.2.1",
|
||||
"opener": "^1.5.2",
|
||||
"rollup": "^2.70.0",
|
||||
"rollup-plugin-dts": "^4.2.3",
|
||||
"tsd": "^0.19.1",
|
||||
"typescript": "^4.6.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:cjs && npm run build:types",
|
||||
"build:cjs": "rollup -c",
|
||||
"build:debug": "npm run build:cjs -- -m && npm run build:types",
|
||||
"build:keys": "node tools/build-keys-from-ts",
|
||||
"build:types": "tsc",
|
||||
"lint": "eslint .",
|
||||
"prepare": "npm run build",
|
||||
"release:generate:latest": "eslint-generate-release",
|
||||
"release:generate:alpha": "eslint-generate-prerelease alpha",
|
||||
"release:generate:beta": "eslint-generate-prerelease beta",
|
||||
"release:generate:rc": "eslint-generate-prerelease rc",
|
||||
"release:publish": "eslint-publish-release",
|
||||
"test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js && npm run test:types",
|
||||
"test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html",
|
||||
"test:types": "tsd"
|
||||
},
|
||||
"repository": "eslint/eslint-visitor-keys",
|
||||
"funding": "https://opencollective.com/eslint",
|
||||
"keywords": [],
|
||||
"author": "Toru Nagashima (https://github.com/mysticatea)",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/eslint-visitor-keys/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/eslint-visitor-keys#readme"
|
||||
}
|
||||
25
node_modules/@eslint/eslintrc/node_modules/espree/LICENSE
generated
vendored
Normal file
25
node_modules/@eslint/eslintrc/node_modules/espree/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) Open JS Foundation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
244
node_modules/@eslint/eslintrc/node_modules/espree/README.md
generated
vendored
Normal file
244
node_modules/@eslint/eslintrc/node_modules/espree/README.md
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
[](https://www.npmjs.com/package/espree)
|
||||
[](https://www.npmjs.com/package/espree)
|
||||
[](https://github.com/eslint/espree/actions)
|
||||
[](https://www.bountysource.com/trackers/9348450-eslint?utm_source=9348450&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
||||
|
||||
# Espree
|
||||
|
||||
Espree started out as a fork of [Esprima](http://esprima.org) v1.2.2, the last stable published released of Esprima before work on ECMAScript 6 began. Espree is now built on top of [Acorn](https://github.com/ternjs/acorn), which has a modular architecture that allows extension of core functionality. The goal of Espree is to produce output that is similar to Esprima with a similar API so that it can be used in place of Esprima.
|
||||
|
||||
## Usage
|
||||
|
||||
Install:
|
||||
|
||||
```
|
||||
npm i espree
|
||||
```
|
||||
|
||||
To use in an ESM file:
|
||||
|
||||
```js
|
||||
import * as espree from "espree";
|
||||
|
||||
const ast = espree.parse(code);
|
||||
```
|
||||
|
||||
To use in a Common JS file:
|
||||
|
||||
```js
|
||||
const espree = require("espree");
|
||||
|
||||
const ast = espree.parse(code);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `parse()`
|
||||
|
||||
`parse` parses the given code and returns a abstract syntax tree (AST). It takes two parameters.
|
||||
|
||||
- `code` [string]() - the code which needs to be parsed.
|
||||
- `options (Optional)` [Object]() - read more about this [here](#options).
|
||||
|
||||
```js
|
||||
import * as espree from "espree";
|
||||
|
||||
const ast = espree.parse(code);
|
||||
```
|
||||
|
||||
**Example :**
|
||||
|
||||
```js
|
||||
const ast = espree.parse('let foo = "bar"', { ecmaVersion: 6 });
|
||||
console.log(ast);
|
||||
```
|
||||
|
||||
<details><summary>Output</summary>
|
||||
<p>
|
||||
|
||||
```
|
||||
Node {
|
||||
type: 'Program',
|
||||
start: 0,
|
||||
end: 15,
|
||||
body: [
|
||||
Node {
|
||||
type: 'VariableDeclaration',
|
||||
start: 0,
|
||||
end: 15,
|
||||
declarations: [Array],
|
||||
kind: 'let'
|
||||
}
|
||||
],
|
||||
sourceType: 'script'
|
||||
}
|
||||
```
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
### `tokenize()`
|
||||
|
||||
`tokenize` returns the tokens of a given code. It takes two parameters.
|
||||
|
||||
- `code` [string]() - the code which needs to be parsed.
|
||||
- `options (Optional)` [Object]() - read more about this [here](#options).
|
||||
|
||||
Even if `options` is empty or undefined or `options.tokens` is `false`, it assigns it to `true` in order to get the `tokens` array
|
||||
|
||||
**Example :**
|
||||
|
||||
```js
|
||||
import * as espree from "espree";
|
||||
|
||||
const tokens = espree.tokenize('let foo = "bar"', { ecmaVersion: 6 });
|
||||
console.log(tokens);
|
||||
```
|
||||
|
||||
<details><summary>Output</summary>
|
||||
<p>
|
||||
|
||||
```
|
||||
Token { type: 'Keyword', value: 'let', start: 0, end: 3 },
|
||||
Token { type: 'Identifier', value: 'foo', start: 4, end: 7 },
|
||||
Token { type: 'Punctuator', value: '=', start: 8, end: 9 },
|
||||
Token { type: 'String', value: '"bar"', start: 10, end: 15 }
|
||||
```
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
### `version`
|
||||
|
||||
Returns the current `espree` version
|
||||
|
||||
### `VisitorKeys`
|
||||
|
||||
Returns all visitor keys for traversing the AST from [eslint-visitor-keys](https://github.com/eslint/eslint-visitor-keys)
|
||||
|
||||
### `latestEcmaVersion`
|
||||
|
||||
Returns the latest ECMAScript supported by `espree`
|
||||
|
||||
### `supportedEcmaVersions`
|
||||
|
||||
Returns an array of all supported ECMAScript versions
|
||||
|
||||
## Options
|
||||
|
||||
```js
|
||||
const options = {
|
||||
// attach range information to each node
|
||||
range: false,
|
||||
|
||||
// attach line/column location information to each node
|
||||
loc: false,
|
||||
|
||||
// create a top-level comments array containing all comments
|
||||
comment: false,
|
||||
|
||||
// create a top-level tokens array containing all tokens
|
||||
tokens: false,
|
||||
|
||||
// Set to 3, 5 (the default), 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 or 16 to specify the version of ECMAScript syntax you want to use.
|
||||
// You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), 2022 (same as 13), 2023 (same as 14), 2024 (same as 15) or 2025 (same as 16) to use the year-based naming.
|
||||
// You can also set "latest" to use the most recently supported version.
|
||||
ecmaVersion: 3,
|
||||
|
||||
allowReserved: true, // only allowed when ecmaVersion is 3
|
||||
|
||||
// specify which type of script you're parsing ("script", "module", or "commonjs")
|
||||
sourceType: "script",
|
||||
|
||||
// specify additional language features
|
||||
ecmaFeatures: {
|
||||
|
||||
// enable JSX parsing
|
||||
jsx: false,
|
||||
|
||||
// enable return in global scope (set to true automatically when sourceType is "commonjs")
|
||||
globalReturn: false,
|
||||
|
||||
// enable implied strict mode (if ecmaVersion >= 5)
|
||||
impliedStrict: false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Esprima Compatibility Going Forward
|
||||
|
||||
The primary goal is to produce the exact same AST structure and tokens as Esprima, and that takes precedence over anything else. (The AST structure being the [ESTree](https://github.com/estree/estree) API with JSX extensions.) Separate from that, Espree may deviate from what Esprima outputs in terms of where and how comments are attached, as well as what additional information is available on AST nodes. That is to say, Espree may add more things to the AST nodes than Esprima does but the overall AST structure produced will be the same.
|
||||
|
||||
Espree may also deviate from Esprima in the interface it exposes.
|
||||
|
||||
## Contributing
|
||||
|
||||
Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/espree/issues).
|
||||
|
||||
Espree is licensed under a permissive BSD 2-clause license.
|
||||
|
||||
## Security Policy
|
||||
|
||||
We work hard to ensure that Espree is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).
|
||||
|
||||
## Build Commands
|
||||
|
||||
* `npm test` - run all tests
|
||||
* `npm run lint` - run all linting
|
||||
|
||||
## Differences from Espree 2.x
|
||||
|
||||
* The `tokenize()` method does not use `ecmaFeatures`. Any string will be tokenized completely based on ECMAScript 6 semantics.
|
||||
* Trailing whitespace no longer is counted as part of a node.
|
||||
* `let` and `const` declarations are no longer parsed by default. You must opt-in by using an `ecmaVersion` newer than `5` or setting `sourceType` to `module`.
|
||||
* The `esparse` and `esvalidate` binary scripts have been removed.
|
||||
* There is no `tolerant` option. We will investigate adding this back in the future.
|
||||
|
||||
## Known Incompatibilities
|
||||
|
||||
In an effort to help those wanting to transition from other parsers to Espree, the following is a list of noteworthy incompatibilities with other parsers. These are known differences that we do not intend to change.
|
||||
|
||||
### Esprima 1.2.2
|
||||
|
||||
* Esprima counts trailing whitespace as part of each AST node while Espree does not. In Espree, the end of a node is where the last token occurs.
|
||||
* Espree does not parse `let` and `const` declarations by default.
|
||||
* Error messages returned for parsing errors are different.
|
||||
* There are two addition properties on every node and token: `start` and `end`. These represent the same data as `range` and are used internally by Acorn.
|
||||
|
||||
### Esprima 2.x
|
||||
|
||||
* Esprima 2.x uses a different comment attachment algorithm that results in some comments being added in different places than Espree. The algorithm Espree uses is the same one used in Esprima 1.2.2.
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### Why another parser
|
||||
|
||||
[ESLint](http://eslint.org) had been relying on Esprima as its parser from the beginning. While that was fine when the JavaScript language was evolving slowly, the pace of development increased dramatically and Esprima had fallen behind. ESLint, like many other tools reliant on Esprima, has been stuck in using new JavaScript language features until Esprima updates, and that caused our users frustration.
|
||||
|
||||
We decided the only way for us to move forward was to create our own parser, bringing us inline with JSHint and JSLint, and allowing us to keep implementing new features as we need them. We chose to fork Esprima instead of starting from scratch in order to move as quickly as possible with a compatible API.
|
||||
|
||||
With Espree 2.0.0, we are no longer a fork of Esprima but rather a translation layer between Acorn and Esprima syntax. This allows us to put work back into a community-supported parser (Acorn) that is continuing to grow and evolve while maintaining an Esprima-compatible parser for those utilities still built on Esprima.
|
||||
|
||||
### Have you tried working with Esprima?
|
||||
|
||||
Yes. Since the start of ESLint, we've regularly filed bugs and feature requests with Esprima and will continue to do so. However, there are some different philosophies around how the projects work that need to be worked through. The initial goal was to have Espree track Esprima and eventually merge the two back together, but we ultimately decided that building on top of Acorn was a better choice due to Acorn's plugin support.
|
||||
|
||||
### Why don't you just use Acorn?
|
||||
|
||||
Acorn is a great JavaScript parser that produces an AST that is compatible with Esprima. Unfortunately, ESLint relies on more than just the AST to do its job. It relies on Esprima's tokens and comment attachment features to get a complete picture of the source code. We investigated switching to Acorn, but the inconsistencies between Esprima and Acorn created too much work for a project like ESLint.
|
||||
|
||||
We are building on top of Acorn, however, so that we can contribute back and help make Acorn even better.
|
||||
|
||||
### What ECMAScript features do you support?
|
||||
|
||||
Espree supports all ECMAScript 2024 features and partially supports ECMAScript 2025 features.
|
||||
|
||||
Because ECMAScript 2025 is still under development, we are implementing features as they are finalized. Currently, Espree supports:
|
||||
|
||||
* [RegExp Duplicate named capturing groups](https://github.com/tc39/proposal-duplicate-named-capturing-groups)
|
||||
|
||||
See [finished-proposals.md](https://github.com/tc39/proposals/blob/master/finished-proposals.md) to know what features are finalized.
|
||||
|
||||
### How do you determine which experimental features to support?
|
||||
|
||||
In general, we do not support experimental JavaScript features. We may make exceptions from time to time depending on the maturity of the features.
|
||||
939
node_modules/@eslint/eslintrc/node_modules/espree/dist/espree.cjs
generated
vendored
Normal file
939
node_modules/@eslint/eslintrc/node_modules/espree/dist/espree.cjs
generated
vendored
Normal file
@@ -0,0 +1,939 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var acorn = require('acorn');
|
||||
var jsx = require('acorn-jsx');
|
||||
var visitorKeys = require('eslint-visitor-keys');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn);
|
||||
var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
|
||||
var visitorKeys__namespace = /*#__PURE__*/_interopNamespace(visitorKeys);
|
||||
|
||||
/**
|
||||
* @fileoverview Translates tokens between Acorn format and Esprima format.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// none!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Esprima Token Types
|
||||
const Token = {
|
||||
Boolean: "Boolean",
|
||||
EOF: "<end>",
|
||||
Identifier: "Identifier",
|
||||
PrivateIdentifier: "PrivateIdentifier",
|
||||
Keyword: "Keyword",
|
||||
Null: "Null",
|
||||
Numeric: "Numeric",
|
||||
Punctuator: "Punctuator",
|
||||
String: "String",
|
||||
RegularExpression: "RegularExpression",
|
||||
Template: "Template",
|
||||
JSXIdentifier: "JSXIdentifier",
|
||||
JSXText: "JSXText"
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts part of a template into an Esprima token.
|
||||
* @param {AcornToken[]} tokens The Acorn tokens representing the template.
|
||||
* @param {string} code The source code.
|
||||
* @returns {EsprimaToken} The Esprima equivalent of the template token.
|
||||
* @private
|
||||
*/
|
||||
function convertTemplatePart(tokens, code) {
|
||||
const firstToken = tokens[0],
|
||||
lastTemplateToken = tokens.at(-1);
|
||||
|
||||
const token = {
|
||||
type: Token.Template,
|
||||
value: code.slice(firstToken.start, lastTemplateToken.end)
|
||||
};
|
||||
|
||||
if (firstToken.loc) {
|
||||
token.loc = {
|
||||
start: firstToken.loc.start,
|
||||
end: lastTemplateToken.loc.end
|
||||
};
|
||||
}
|
||||
|
||||
if (firstToken.range) {
|
||||
token.start = firstToken.range[0];
|
||||
token.end = lastTemplateToken.range[1];
|
||||
token.range = [token.start, token.end];
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains logic to translate Acorn tokens into Esprima tokens.
|
||||
* @param {Object} acornTokTypes The Acorn token types.
|
||||
* @param {string} code The source code Acorn is parsing. This is necessary
|
||||
* to correct the "value" property of some tokens.
|
||||
* @constructor
|
||||
*/
|
||||
function TokenTranslator(acornTokTypes, code) {
|
||||
|
||||
// token types
|
||||
this._acornTokTypes = acornTokTypes;
|
||||
|
||||
// token buffer for templates
|
||||
this._tokens = [];
|
||||
|
||||
// track the last curly brace
|
||||
this._curlyBrace = null;
|
||||
|
||||
// the source code
|
||||
this._code = code;
|
||||
|
||||
}
|
||||
|
||||
TokenTranslator.prototype = {
|
||||
constructor: TokenTranslator,
|
||||
|
||||
/**
|
||||
* Translates a single Esprima token to a single Acorn token. This may be
|
||||
* inaccurate due to how templates are handled differently in Esprima and
|
||||
* Acorn, but should be accurate for all other tokens.
|
||||
* @param {AcornToken} token The Acorn token to translate.
|
||||
* @param {Object} extra Espree extra object.
|
||||
* @returns {EsprimaToken} The Esprima version of the token.
|
||||
*/
|
||||
translate(token, extra) {
|
||||
|
||||
const type = token.type,
|
||||
tt = this._acornTokTypes;
|
||||
|
||||
if (type === tt.name) {
|
||||
token.type = Token.Identifier;
|
||||
|
||||
// TODO: See if this is an Acorn bug
|
||||
if (token.value === "static") {
|
||||
token.type = Token.Keyword;
|
||||
}
|
||||
|
||||
if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) {
|
||||
token.type = Token.Keyword;
|
||||
}
|
||||
|
||||
} else if (type === tt.privateId) {
|
||||
token.type = Token.PrivateIdentifier;
|
||||
|
||||
} else if (type === tt.semi || type === tt.comma ||
|
||||
type === tt.parenL || type === tt.parenR ||
|
||||
type === tt.braceL || type === tt.braceR ||
|
||||
type === tt.dot || type === tt.bracketL ||
|
||||
type === tt.colon || type === tt.question ||
|
||||
type === tt.bracketR || type === tt.ellipsis ||
|
||||
type === tt.arrow || type === tt.jsxTagStart ||
|
||||
type === tt.incDec || type === tt.starstar ||
|
||||
type === tt.jsxTagEnd || type === tt.prefix ||
|
||||
type === tt.questionDot ||
|
||||
(type.binop && !type.keyword) ||
|
||||
type.isAssign) {
|
||||
|
||||
token.type = Token.Punctuator;
|
||||
token.value = this._code.slice(token.start, token.end);
|
||||
} else if (type === tt.jsxName) {
|
||||
token.type = Token.JSXIdentifier;
|
||||
} else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) {
|
||||
token.type = Token.JSXText;
|
||||
} else if (type.keyword) {
|
||||
if (type.keyword === "true" || type.keyword === "false") {
|
||||
token.type = Token.Boolean;
|
||||
} else if (type.keyword === "null") {
|
||||
token.type = Token.Null;
|
||||
} else {
|
||||
token.type = Token.Keyword;
|
||||
}
|
||||
} else if (type === tt.num) {
|
||||
token.type = Token.Numeric;
|
||||
token.value = this._code.slice(token.start, token.end);
|
||||
} else if (type === tt.string) {
|
||||
|
||||
if (extra.jsxAttrValueToken) {
|
||||
extra.jsxAttrValueToken = false;
|
||||
token.type = Token.JSXText;
|
||||
} else {
|
||||
token.type = Token.String;
|
||||
}
|
||||
|
||||
token.value = this._code.slice(token.start, token.end);
|
||||
} else if (type === tt.regexp) {
|
||||
token.type = Token.RegularExpression;
|
||||
const value = token.value;
|
||||
|
||||
token.regex = {
|
||||
flags: value.flags,
|
||||
pattern: value.pattern
|
||||
};
|
||||
token.value = `/${value.pattern}/${value.flags}`;
|
||||
}
|
||||
|
||||
return token;
|
||||
},
|
||||
|
||||
/**
|
||||
* Function to call during Acorn's onToken handler.
|
||||
* @param {AcornToken} token The Acorn token.
|
||||
* @param {Object} extra The Espree extra object.
|
||||
* @returns {void}
|
||||
*/
|
||||
onToken(token, extra) {
|
||||
|
||||
const tt = this._acornTokTypes,
|
||||
tokens = extra.tokens,
|
||||
templateTokens = this._tokens;
|
||||
|
||||
/**
|
||||
* Flushes the buffered template tokens and resets the template
|
||||
* tracking.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
const translateTemplateTokens = () => {
|
||||
tokens.push(convertTemplatePart(this._tokens, this._code));
|
||||
this._tokens = [];
|
||||
};
|
||||
|
||||
if (token.type === tt.eof) {
|
||||
|
||||
// might be one last curlyBrace
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (token.type === tt.backQuote) {
|
||||
|
||||
// if there's already a curly, it's not part of the template
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
this._curlyBrace = null;
|
||||
}
|
||||
|
||||
templateTokens.push(token);
|
||||
|
||||
// it's the end
|
||||
if (templateTokens.length > 1) {
|
||||
translateTemplateTokens();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (token.type === tt.dollarBraceL) {
|
||||
templateTokens.push(token);
|
||||
translateTemplateTokens();
|
||||
return;
|
||||
}
|
||||
if (token.type === tt.braceR) {
|
||||
|
||||
// if there's already a curly, it's not part of the template
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
}
|
||||
|
||||
// store new curly for later
|
||||
this._curlyBrace = token;
|
||||
return;
|
||||
}
|
||||
if (token.type === tt.template || token.type === tt.invalidTemplate) {
|
||||
if (this._curlyBrace) {
|
||||
templateTokens.push(this._curlyBrace);
|
||||
this._curlyBrace = null;
|
||||
}
|
||||
|
||||
templateTokens.push(token);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
this._curlyBrace = null;
|
||||
}
|
||||
|
||||
tokens.push(this.translate(token, extra));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @fileoverview A collection of methods for processing Espree's options.
|
||||
* @author Kai Cataldo
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const SUPPORTED_VERSIONS = [
|
||||
3,
|
||||
5,
|
||||
6, // 2015
|
||||
7, // 2016
|
||||
8, // 2017
|
||||
9, // 2018
|
||||
10, // 2019
|
||||
11, // 2020
|
||||
12, // 2021
|
||||
13, // 2022
|
||||
14, // 2023
|
||||
15, // 2024
|
||||
16 // 2025
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the latest ECMAScript version supported by Espree.
|
||||
* @returns {number} The latest ECMAScript version.
|
||||
*/
|
||||
function getLatestEcmaVersion() {
|
||||
return SUPPORTED_VERSIONS.at(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of ECMAScript versions supported by Espree.
|
||||
* @returns {number[]} An array containing the supported ECMAScript versions.
|
||||
*/
|
||||
function getSupportedEcmaVersions() {
|
||||
return [...SUPPORTED_VERSIONS];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize ECMAScript version from the initial config
|
||||
* @param {(number|"latest")} ecmaVersion ECMAScript version from the initial config
|
||||
* @throws {Error} throws an error if the ecmaVersion is invalid.
|
||||
* @returns {number} normalized ECMAScript version
|
||||
*/
|
||||
function normalizeEcmaVersion(ecmaVersion = 5) {
|
||||
|
||||
let version = ecmaVersion === "latest" ? getLatestEcmaVersion() : ecmaVersion;
|
||||
|
||||
if (typeof version !== "number") {
|
||||
throw new Error(`ecmaVersion must be a number or "latest". Received value of type ${typeof ecmaVersion} instead.`);
|
||||
}
|
||||
|
||||
// Calculate ECMAScript edition number from official year version starting with
|
||||
// ES2015, which corresponds with ES6 (or a difference of 2009).
|
||||
if (version >= 2015) {
|
||||
version -= 2009;
|
||||
}
|
||||
|
||||
if (!SUPPORTED_VERSIONS.includes(version)) {
|
||||
throw new Error("Invalid ecmaVersion.");
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize sourceType from the initial config
|
||||
* @param {string} sourceType to normalize
|
||||
* @throws {Error} throw an error if sourceType is invalid
|
||||
* @returns {string} normalized sourceType
|
||||
*/
|
||||
function normalizeSourceType(sourceType = "script") {
|
||||
if (sourceType === "script" || sourceType === "module") {
|
||||
return sourceType;
|
||||
}
|
||||
|
||||
if (sourceType === "commonjs") {
|
||||
return "script";
|
||||
}
|
||||
|
||||
throw new Error("Invalid sourceType.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize parserOptions
|
||||
* @param {Object} options the parser options to normalize
|
||||
* @throws {Error} throw an error if found invalid option.
|
||||
* @returns {Object} normalized options
|
||||
*/
|
||||
function normalizeOptions(options) {
|
||||
const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
|
||||
const sourceType = normalizeSourceType(options.sourceType);
|
||||
const ranges = options.range === true;
|
||||
const locations = options.loc === true;
|
||||
|
||||
if (ecmaVersion !== 3 && options.allowReserved) {
|
||||
|
||||
// a value of `false` is intentionally allowed here, so a shared config can overwrite it when needed
|
||||
throw new Error("`allowReserved` is only supported when ecmaVersion is 3");
|
||||
}
|
||||
if (typeof options.allowReserved !== "undefined" && typeof options.allowReserved !== "boolean") {
|
||||
throw new Error("`allowReserved`, when present, must be `true` or `false`");
|
||||
}
|
||||
const allowReserved = ecmaVersion === 3 ? (options.allowReserved || "never") : false;
|
||||
const ecmaFeatures = options.ecmaFeatures || {};
|
||||
const allowReturnOutsideFunction = options.sourceType === "commonjs" ||
|
||||
Boolean(ecmaFeatures.globalReturn);
|
||||
|
||||
if (sourceType === "module" && ecmaVersion < 6) {
|
||||
throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
|
||||
}
|
||||
|
||||
return Object.assign({}, options, {
|
||||
ecmaVersion,
|
||||
sourceType,
|
||||
ranges,
|
||||
locations,
|
||||
allowReserved,
|
||||
allowReturnOutsideFunction
|
||||
});
|
||||
}
|
||||
|
||||
/* eslint no-param-reassign: 0 -- stylistic choice */
|
||||
|
||||
|
||||
const STATE = Symbol("espree's internal state");
|
||||
const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
|
||||
|
||||
|
||||
/**
|
||||
* Converts an Acorn comment to a Esprima comment.
|
||||
* @param {boolean} block True if it's a block comment, false if not.
|
||||
* @param {string} text The text of the comment.
|
||||
* @param {int} start The index at which the comment starts.
|
||||
* @param {int} end The index at which the comment ends.
|
||||
* @param {Location} startLoc The location at which the comment starts.
|
||||
* @param {Location} endLoc The location at which the comment ends.
|
||||
* @param {string} code The source code being parsed.
|
||||
* @returns {Object} The comment object.
|
||||
* @private
|
||||
*/
|
||||
function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code) {
|
||||
let type;
|
||||
|
||||
if (block) {
|
||||
type = "Block";
|
||||
} else if (code.slice(start, start + 2) === "#!") {
|
||||
type = "Hashbang";
|
||||
} else {
|
||||
type = "Line";
|
||||
}
|
||||
|
||||
const comment = {
|
||||
type,
|
||||
value: text
|
||||
};
|
||||
|
||||
if (typeof start === "number") {
|
||||
comment.start = start;
|
||||
comment.end = end;
|
||||
comment.range = [start, end];
|
||||
}
|
||||
|
||||
if (typeof startLoc === "object") {
|
||||
comment.loc = {
|
||||
start: startLoc,
|
||||
end: endLoc
|
||||
};
|
||||
}
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
var espree = () => Parser => {
|
||||
const tokTypes = Object.assign({}, Parser.acorn.tokTypes);
|
||||
|
||||
if (Parser.acornJsx) {
|
||||
Object.assign(tokTypes, Parser.acornJsx.tokTypes);
|
||||
}
|
||||
|
||||
return class Espree extends Parser {
|
||||
constructor(opts, code) {
|
||||
if (typeof opts !== "object" || opts === null) {
|
||||
opts = {};
|
||||
}
|
||||
if (typeof code !== "string" && !(code instanceof String)) {
|
||||
code = String(code);
|
||||
}
|
||||
|
||||
// save original source type in case of commonjs
|
||||
const originalSourceType = opts.sourceType;
|
||||
const options = normalizeOptions(opts);
|
||||
const ecmaFeatures = options.ecmaFeatures || {};
|
||||
const tokenTranslator =
|
||||
options.tokens === true
|
||||
? new TokenTranslator(tokTypes, code)
|
||||
: null;
|
||||
|
||||
/*
|
||||
* Data that is unique to Espree and is not represented internally
|
||||
* in Acorn.
|
||||
*
|
||||
* For ES2023 hashbangs, Espree will call `onComment()` during the
|
||||
* constructor, so we must define state before having access to
|
||||
* `this`.
|
||||
*/
|
||||
const state = {
|
||||
originalSourceType: originalSourceType || options.sourceType,
|
||||
tokens: tokenTranslator ? [] : null,
|
||||
comments: options.comment === true ? [] : null,
|
||||
impliedStrict: ecmaFeatures.impliedStrict === true && options.ecmaVersion >= 5,
|
||||
ecmaVersion: options.ecmaVersion,
|
||||
jsxAttrValueToken: false,
|
||||
lastToken: null,
|
||||
templateElements: []
|
||||
};
|
||||
|
||||
// Initialize acorn parser.
|
||||
super({
|
||||
|
||||
// do not use spread, because we don't want to pass any unknown options to acorn
|
||||
ecmaVersion: options.ecmaVersion,
|
||||
sourceType: options.sourceType,
|
||||
ranges: options.ranges,
|
||||
locations: options.locations,
|
||||
allowReserved: options.allowReserved,
|
||||
|
||||
// Truthy value is true for backward compatibility.
|
||||
allowReturnOutsideFunction: options.allowReturnOutsideFunction,
|
||||
|
||||
// Collect tokens
|
||||
onToken(token) {
|
||||
if (tokenTranslator) {
|
||||
|
||||
// Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
|
||||
tokenTranslator.onToken(token, state);
|
||||
}
|
||||
if (token.type !== tokTypes.eof) {
|
||||
state.lastToken = token;
|
||||
}
|
||||
},
|
||||
|
||||
// Collect comments
|
||||
onComment(block, text, start, end, startLoc, endLoc) {
|
||||
if (state.comments) {
|
||||
const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code);
|
||||
|
||||
state.comments.push(comment);
|
||||
}
|
||||
}
|
||||
}, code);
|
||||
|
||||
/*
|
||||
* We put all of this data into a symbol property as a way to avoid
|
||||
* potential naming conflicts with future versions of Acorn.
|
||||
*/
|
||||
this[STATE] = state;
|
||||
}
|
||||
|
||||
tokenize() {
|
||||
do {
|
||||
this.next();
|
||||
} while (this.type !== tokTypes.eof);
|
||||
|
||||
// Consume the final eof token
|
||||
this.next();
|
||||
|
||||
const extra = this[STATE];
|
||||
const tokens = extra.tokens;
|
||||
|
||||
if (extra.comments) {
|
||||
tokens.comments = extra.comments;
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
finishNode(...args) {
|
||||
const result = super.finishNode(...args);
|
||||
|
||||
return this[ESPRIMA_FINISH_NODE](result);
|
||||
}
|
||||
|
||||
finishNodeAt(...args) {
|
||||
const result = super.finishNodeAt(...args);
|
||||
|
||||
return this[ESPRIMA_FINISH_NODE](result);
|
||||
}
|
||||
|
||||
parse() {
|
||||
const extra = this[STATE];
|
||||
const program = super.parse();
|
||||
|
||||
program.sourceType = extra.originalSourceType;
|
||||
|
||||
if (extra.comments) {
|
||||
program.comments = extra.comments;
|
||||
}
|
||||
if (extra.tokens) {
|
||||
program.tokens = extra.tokens;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adjust opening and closing position of program to match Esprima.
|
||||
* Acorn always starts programs at range 0 whereas Esprima starts at the
|
||||
* first AST node's start (the only real difference is when there's leading
|
||||
* whitespace or leading comments). Acorn also counts trailing whitespace
|
||||
* as part of the program whereas Esprima only counts up to the last token.
|
||||
*/
|
||||
if (program.body.length) {
|
||||
const [firstNode] = program.body;
|
||||
|
||||
if (program.range) {
|
||||
program.range[0] = firstNode.range[0];
|
||||
}
|
||||
if (program.loc) {
|
||||
program.loc.start = firstNode.loc.start;
|
||||
}
|
||||
program.start = firstNode.start;
|
||||
}
|
||||
if (extra.lastToken) {
|
||||
if (program.range) {
|
||||
program.range[1] = extra.lastToken.range[1];
|
||||
}
|
||||
if (program.loc) {
|
||||
program.loc.end = extra.lastToken.loc.end;
|
||||
}
|
||||
program.end = extra.lastToken.end;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* https://github.com/eslint/espree/issues/349
|
||||
* Ensure that template elements have correct range information.
|
||||
* This is one location where Acorn produces a different value
|
||||
* for its start and end properties vs. the values present in the
|
||||
* range property. In order to avoid confusion, we set the start
|
||||
* and end properties to the values that are present in range.
|
||||
* This is done here, instead of in finishNode(), because Acorn
|
||||
* uses the values of start and end internally while parsing, making
|
||||
* it dangerous to change those values while parsing is ongoing.
|
||||
* By waiting until the end of parsing, we can safely change these
|
||||
* values without affect any other part of the process.
|
||||
*/
|
||||
this[STATE].templateElements.forEach(templateElement => {
|
||||
const startOffset = -1;
|
||||
const endOffset = templateElement.tail ? 1 : 2;
|
||||
|
||||
templateElement.start += startOffset;
|
||||
templateElement.end += endOffset;
|
||||
|
||||
if (templateElement.range) {
|
||||
templateElement.range[0] += startOffset;
|
||||
templateElement.range[1] += endOffset;
|
||||
}
|
||||
|
||||
if (templateElement.loc) {
|
||||
templateElement.loc.start.column += startOffset;
|
||||
templateElement.loc.end.column += endOffset;
|
||||
}
|
||||
});
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
parseTopLevel(node) {
|
||||
if (this[STATE].impliedStrict) {
|
||||
this.strict = true;
|
||||
}
|
||||
return super.parseTopLevel(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the default raise method to throw Esprima-style errors.
|
||||
* @param {int} pos The position of the error.
|
||||
* @param {string} message The error message.
|
||||
* @throws {SyntaxError} A syntax error.
|
||||
* @returns {void}
|
||||
*/
|
||||
raise(pos, message) {
|
||||
const loc = Parser.acorn.getLineInfo(this.input, pos);
|
||||
const err = new SyntaxError(message);
|
||||
|
||||
err.index = pos;
|
||||
err.lineNumber = loc.line;
|
||||
err.column = loc.column + 1; // acorn uses 0-based columns
|
||||
throw err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the default raise method to throw Esprima-style errors.
|
||||
* @param {int} pos The position of the error.
|
||||
* @param {string} message The error message.
|
||||
* @throws {SyntaxError} A syntax error.
|
||||
* @returns {void}
|
||||
*/
|
||||
raiseRecoverable(pos, message) {
|
||||
this.raise(pos, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the default unexpected method to throw Esprima-style errors.
|
||||
* @param {int} pos The position of the error.
|
||||
* @throws {SyntaxError} A syntax error.
|
||||
* @returns {void}
|
||||
*/
|
||||
unexpected(pos) {
|
||||
let message = "Unexpected token";
|
||||
|
||||
if (pos !== null && pos !== void 0) {
|
||||
this.pos = pos;
|
||||
|
||||
if (this.options.locations) {
|
||||
while (this.pos < this.lineStart) {
|
||||
this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
|
||||
--this.curLine;
|
||||
}
|
||||
}
|
||||
|
||||
this.nextToken();
|
||||
}
|
||||
|
||||
if (this.end > this.start) {
|
||||
message += ` ${this.input.slice(this.start, this.end)}`;
|
||||
}
|
||||
|
||||
this.raise(this.start, message);
|
||||
}
|
||||
|
||||
/*
|
||||
* Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX
|
||||
* uses regular tt.string without any distinction between this and regular JS
|
||||
* strings. As such, we intercept an attempt to read a JSX string and set a flag
|
||||
* on extra so that when tokens are converted, the next token will be switched
|
||||
* to JSXText via onToken.
|
||||
*/
|
||||
jsx_readString(quote) { // eslint-disable-line camelcase -- required by API
|
||||
const result = super.jsx_readString(quote);
|
||||
|
||||
if (this.type === tokTypes.string) {
|
||||
this[STATE].jsxAttrValueToken = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs last-minute Esprima-specific compatibility checks and fixes.
|
||||
* @param {ASTNode} result The node to check.
|
||||
* @returns {ASTNode} The finished node.
|
||||
*/
|
||||
[ESPRIMA_FINISH_NODE](result) {
|
||||
|
||||
// Acorn doesn't count the opening and closing backticks as part of templates
|
||||
// so we have to adjust ranges/locations appropriately.
|
||||
if (result.type === "TemplateElement") {
|
||||
|
||||
// save template element references to fix start/end later
|
||||
this[STATE].templateElements.push(result);
|
||||
}
|
||||
|
||||
if (result.type.includes("Function") && !result.generator) {
|
||||
result.generator = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const version$1 = "10.1.0";
|
||||
|
||||
/**
|
||||
* @fileoverview Main Espree file that converts Acorn into Esprima output.
|
||||
*
|
||||
* This file contains code from the following MIT-licensed projects:
|
||||
* 1. Acorn
|
||||
* 2. Babylon
|
||||
* 3. Babel-ESLint
|
||||
*
|
||||
* This file also contains code from Esprima, which is BSD licensed.
|
||||
*
|
||||
* Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
|
||||
* Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
|
||||
* Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
// To initialize lazily.
|
||||
const parsers = {
|
||||
_regular: null,
|
||||
_jsx: null,
|
||||
|
||||
get regular() {
|
||||
if (this._regular === null) {
|
||||
this._regular = acorn__namespace.Parser.extend(espree());
|
||||
}
|
||||
return this._regular;
|
||||
},
|
||||
|
||||
get jsx() {
|
||||
if (this._jsx === null) {
|
||||
this._jsx = acorn__namespace.Parser.extend(jsx__default["default"](), espree());
|
||||
}
|
||||
return this._jsx;
|
||||
},
|
||||
|
||||
get(options) {
|
||||
const useJsx = Boolean(
|
||||
options &&
|
||||
options.ecmaFeatures &&
|
||||
options.ecmaFeatures.jsx
|
||||
);
|
||||
|
||||
return useJsx ? this.jsx : this.regular;
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Tokenizer
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tokenizes the given code.
|
||||
* @param {string} code The code to tokenize.
|
||||
* @param {Object} options Options defining how to tokenize.
|
||||
* @returns {Token[]} An array of tokens.
|
||||
* @throws {SyntaxError} If the input code is invalid.
|
||||
* @private
|
||||
*/
|
||||
function tokenize(code, options) {
|
||||
const Parser = parsers.get(options);
|
||||
|
||||
// Ensure to collect tokens.
|
||||
if (!options || options.tokens !== true) {
|
||||
options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign -- stylistic choice
|
||||
}
|
||||
|
||||
return new Parser(options, code).tokenize();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Parser
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parses the given code.
|
||||
* @param {string} code The code to tokenize.
|
||||
* @param {Object} options Options defining how to tokenize.
|
||||
* @returns {ASTNode} The "Program" AST node.
|
||||
* @throws {SyntaxError} If the input code is invalid.
|
||||
*/
|
||||
function parse(code, options) {
|
||||
const Parser = parsers.get(options);
|
||||
|
||||
return new Parser(options, code).parse();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const version = version$1;
|
||||
const name = "espree";
|
||||
|
||||
/* istanbul ignore next */
|
||||
const VisitorKeys = (function() {
|
||||
return visitorKeys__namespace.KEYS;
|
||||
}());
|
||||
|
||||
// Derive node types from VisitorKeys
|
||||
/* istanbul ignore next */
|
||||
const Syntax = (function() {
|
||||
let key,
|
||||
types = {};
|
||||
|
||||
if (typeof Object.create === "function") {
|
||||
types = Object.create(null);
|
||||
}
|
||||
|
||||
for (key in VisitorKeys) {
|
||||
if (Object.hasOwn(VisitorKeys, key)) {
|
||||
types[key] = key;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof Object.freeze === "function") {
|
||||
Object.freeze(types);
|
||||
}
|
||||
|
||||
return types;
|
||||
}());
|
||||
|
||||
const latestEcmaVersion = getLatestEcmaVersion();
|
||||
|
||||
const supportedEcmaVersions = getSupportedEcmaVersions();
|
||||
|
||||
exports.Syntax = Syntax;
|
||||
exports.VisitorKeys = VisitorKeys;
|
||||
exports.latestEcmaVersion = latestEcmaVersion;
|
||||
exports.name = name;
|
||||
exports.parse = parse;
|
||||
exports.supportedEcmaVersions = supportedEcmaVersions;
|
||||
exports.tokenize = tokenize;
|
||||
exports.version = version;
|
||||
174
node_modules/@eslint/eslintrc/node_modules/espree/espree.js
generated
vendored
Normal file
174
node_modules/@eslint/eslintrc/node_modules/espree/espree.js
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @fileoverview Main Espree file that converts Acorn into Esprima output.
|
||||
*
|
||||
* This file contains code from the following MIT-licensed projects:
|
||||
* 1. Acorn
|
||||
* 2. Babylon
|
||||
* 3. Babel-ESLint
|
||||
*
|
||||
* This file also contains code from Esprima, which is BSD licensed.
|
||||
*
|
||||
* Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
|
||||
* Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
|
||||
* Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
import * as acorn from "acorn";
|
||||
import jsx from "acorn-jsx";
|
||||
import espree from "./lib/espree.js";
|
||||
import espreeVersion from "./lib/version.js";
|
||||
import * as visitorKeys from "eslint-visitor-keys";
|
||||
import { getLatestEcmaVersion, getSupportedEcmaVersions } from "./lib/options.js";
|
||||
|
||||
|
||||
// To initialize lazily.
|
||||
const parsers = {
|
||||
_regular: null,
|
||||
_jsx: null,
|
||||
|
||||
get regular() {
|
||||
if (this._regular === null) {
|
||||
this._regular = acorn.Parser.extend(espree());
|
||||
}
|
||||
return this._regular;
|
||||
},
|
||||
|
||||
get jsx() {
|
||||
if (this._jsx === null) {
|
||||
this._jsx = acorn.Parser.extend(jsx(), espree());
|
||||
}
|
||||
return this._jsx;
|
||||
},
|
||||
|
||||
get(options) {
|
||||
const useJsx = Boolean(
|
||||
options &&
|
||||
options.ecmaFeatures &&
|
||||
options.ecmaFeatures.jsx
|
||||
);
|
||||
|
||||
return useJsx ? this.jsx : this.regular;
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Tokenizer
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tokenizes the given code.
|
||||
* @param {string} code The code to tokenize.
|
||||
* @param {Object} options Options defining how to tokenize.
|
||||
* @returns {Token[]} An array of tokens.
|
||||
* @throws {SyntaxError} If the input code is invalid.
|
||||
* @private
|
||||
*/
|
||||
export function tokenize(code, options) {
|
||||
const Parser = parsers.get(options);
|
||||
|
||||
// Ensure to collect tokens.
|
||||
if (!options || options.tokens !== true) {
|
||||
options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign -- stylistic choice
|
||||
}
|
||||
|
||||
return new Parser(options, code).tokenize();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Parser
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parses the given code.
|
||||
* @param {string} code The code to tokenize.
|
||||
* @param {Object} options Options defining how to tokenize.
|
||||
* @returns {ASTNode} The "Program" AST node.
|
||||
* @throws {SyntaxError} If the input code is invalid.
|
||||
*/
|
||||
export function parse(code, options) {
|
||||
const Parser = parsers.get(options);
|
||||
|
||||
return new Parser(options, code).parse();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const version = espreeVersion;
|
||||
export const name = "espree";
|
||||
|
||||
/* istanbul ignore next */
|
||||
export const VisitorKeys = (function() {
|
||||
return visitorKeys.KEYS;
|
||||
}());
|
||||
|
||||
// Derive node types from VisitorKeys
|
||||
/* istanbul ignore next */
|
||||
export const Syntax = (function() {
|
||||
let key,
|
||||
types = {};
|
||||
|
||||
if (typeof Object.create === "function") {
|
||||
types = Object.create(null);
|
||||
}
|
||||
|
||||
for (key in VisitorKeys) {
|
||||
if (Object.hasOwn(VisitorKeys, key)) {
|
||||
types[key] = key;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof Object.freeze === "function") {
|
||||
Object.freeze(types);
|
||||
}
|
||||
|
||||
return types;
|
||||
}());
|
||||
|
||||
export const latestEcmaVersion = getLatestEcmaVersion();
|
||||
|
||||
export const supportedEcmaVersions = getSupportedEcmaVersions();
|
||||
349
node_modules/@eslint/eslintrc/node_modules/espree/lib/espree.js
generated
vendored
Normal file
349
node_modules/@eslint/eslintrc/node_modules/espree/lib/espree.js
generated
vendored
Normal file
@@ -0,0 +1,349 @@
|
||||
/* eslint no-param-reassign: 0 -- stylistic choice */
|
||||
|
||||
import TokenTranslator from "./token-translator.js";
|
||||
import { normalizeOptions } from "./options.js";
|
||||
|
||||
|
||||
const STATE = Symbol("espree's internal state");
|
||||
const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
|
||||
|
||||
|
||||
/**
|
||||
* Converts an Acorn comment to a Esprima comment.
|
||||
* @param {boolean} block True if it's a block comment, false if not.
|
||||
* @param {string} text The text of the comment.
|
||||
* @param {int} start The index at which the comment starts.
|
||||
* @param {int} end The index at which the comment ends.
|
||||
* @param {Location} startLoc The location at which the comment starts.
|
||||
* @param {Location} endLoc The location at which the comment ends.
|
||||
* @param {string} code The source code being parsed.
|
||||
* @returns {Object} The comment object.
|
||||
* @private
|
||||
*/
|
||||
function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code) {
|
||||
let type;
|
||||
|
||||
if (block) {
|
||||
type = "Block";
|
||||
} else if (code.slice(start, start + 2) === "#!") {
|
||||
type = "Hashbang";
|
||||
} else {
|
||||
type = "Line";
|
||||
}
|
||||
|
||||
const comment = {
|
||||
type,
|
||||
value: text
|
||||
};
|
||||
|
||||
if (typeof start === "number") {
|
||||
comment.start = start;
|
||||
comment.end = end;
|
||||
comment.range = [start, end];
|
||||
}
|
||||
|
||||
if (typeof startLoc === "object") {
|
||||
comment.loc = {
|
||||
start: startLoc,
|
||||
end: endLoc
|
||||
};
|
||||
}
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
export default () => Parser => {
|
||||
const tokTypes = Object.assign({}, Parser.acorn.tokTypes);
|
||||
|
||||
if (Parser.acornJsx) {
|
||||
Object.assign(tokTypes, Parser.acornJsx.tokTypes);
|
||||
}
|
||||
|
||||
return class Espree extends Parser {
|
||||
constructor(opts, code) {
|
||||
if (typeof opts !== "object" || opts === null) {
|
||||
opts = {};
|
||||
}
|
||||
if (typeof code !== "string" && !(code instanceof String)) {
|
||||
code = String(code);
|
||||
}
|
||||
|
||||
// save original source type in case of commonjs
|
||||
const originalSourceType = opts.sourceType;
|
||||
const options = normalizeOptions(opts);
|
||||
const ecmaFeatures = options.ecmaFeatures || {};
|
||||
const tokenTranslator =
|
||||
options.tokens === true
|
||||
? new TokenTranslator(tokTypes, code)
|
||||
: null;
|
||||
|
||||
/*
|
||||
* Data that is unique to Espree and is not represented internally
|
||||
* in Acorn.
|
||||
*
|
||||
* For ES2023 hashbangs, Espree will call `onComment()` during the
|
||||
* constructor, so we must define state before having access to
|
||||
* `this`.
|
||||
*/
|
||||
const state = {
|
||||
originalSourceType: originalSourceType || options.sourceType,
|
||||
tokens: tokenTranslator ? [] : null,
|
||||
comments: options.comment === true ? [] : null,
|
||||
impliedStrict: ecmaFeatures.impliedStrict === true && options.ecmaVersion >= 5,
|
||||
ecmaVersion: options.ecmaVersion,
|
||||
jsxAttrValueToken: false,
|
||||
lastToken: null,
|
||||
templateElements: []
|
||||
};
|
||||
|
||||
// Initialize acorn parser.
|
||||
super({
|
||||
|
||||
// do not use spread, because we don't want to pass any unknown options to acorn
|
||||
ecmaVersion: options.ecmaVersion,
|
||||
sourceType: options.sourceType,
|
||||
ranges: options.ranges,
|
||||
locations: options.locations,
|
||||
allowReserved: options.allowReserved,
|
||||
|
||||
// Truthy value is true for backward compatibility.
|
||||
allowReturnOutsideFunction: options.allowReturnOutsideFunction,
|
||||
|
||||
// Collect tokens
|
||||
onToken(token) {
|
||||
if (tokenTranslator) {
|
||||
|
||||
// Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
|
||||
tokenTranslator.onToken(token, state);
|
||||
}
|
||||
if (token.type !== tokTypes.eof) {
|
||||
state.lastToken = token;
|
||||
}
|
||||
},
|
||||
|
||||
// Collect comments
|
||||
onComment(block, text, start, end, startLoc, endLoc) {
|
||||
if (state.comments) {
|
||||
const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code);
|
||||
|
||||
state.comments.push(comment);
|
||||
}
|
||||
}
|
||||
}, code);
|
||||
|
||||
/*
|
||||
* We put all of this data into a symbol property as a way to avoid
|
||||
* potential naming conflicts with future versions of Acorn.
|
||||
*/
|
||||
this[STATE] = state;
|
||||
}
|
||||
|
||||
tokenize() {
|
||||
do {
|
||||
this.next();
|
||||
} while (this.type !== tokTypes.eof);
|
||||
|
||||
// Consume the final eof token
|
||||
this.next();
|
||||
|
||||
const extra = this[STATE];
|
||||
const tokens = extra.tokens;
|
||||
|
||||
if (extra.comments) {
|
||||
tokens.comments = extra.comments;
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
finishNode(...args) {
|
||||
const result = super.finishNode(...args);
|
||||
|
||||
return this[ESPRIMA_FINISH_NODE](result);
|
||||
}
|
||||
|
||||
finishNodeAt(...args) {
|
||||
const result = super.finishNodeAt(...args);
|
||||
|
||||
return this[ESPRIMA_FINISH_NODE](result);
|
||||
}
|
||||
|
||||
parse() {
|
||||
const extra = this[STATE];
|
||||
const program = super.parse();
|
||||
|
||||
program.sourceType = extra.originalSourceType;
|
||||
|
||||
if (extra.comments) {
|
||||
program.comments = extra.comments;
|
||||
}
|
||||
if (extra.tokens) {
|
||||
program.tokens = extra.tokens;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adjust opening and closing position of program to match Esprima.
|
||||
* Acorn always starts programs at range 0 whereas Esprima starts at the
|
||||
* first AST node's start (the only real difference is when there's leading
|
||||
* whitespace or leading comments). Acorn also counts trailing whitespace
|
||||
* as part of the program whereas Esprima only counts up to the last token.
|
||||
*/
|
||||
if (program.body.length) {
|
||||
const [firstNode] = program.body;
|
||||
|
||||
if (program.range) {
|
||||
program.range[0] = firstNode.range[0];
|
||||
}
|
||||
if (program.loc) {
|
||||
program.loc.start = firstNode.loc.start;
|
||||
}
|
||||
program.start = firstNode.start;
|
||||
}
|
||||
if (extra.lastToken) {
|
||||
if (program.range) {
|
||||
program.range[1] = extra.lastToken.range[1];
|
||||
}
|
||||
if (program.loc) {
|
||||
program.loc.end = extra.lastToken.loc.end;
|
||||
}
|
||||
program.end = extra.lastToken.end;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* https://github.com/eslint/espree/issues/349
|
||||
* Ensure that template elements have correct range information.
|
||||
* This is one location where Acorn produces a different value
|
||||
* for its start and end properties vs. the values present in the
|
||||
* range property. In order to avoid confusion, we set the start
|
||||
* and end properties to the values that are present in range.
|
||||
* This is done here, instead of in finishNode(), because Acorn
|
||||
* uses the values of start and end internally while parsing, making
|
||||
* it dangerous to change those values while parsing is ongoing.
|
||||
* By waiting until the end of parsing, we can safely change these
|
||||
* values without affect any other part of the process.
|
||||
*/
|
||||
this[STATE].templateElements.forEach(templateElement => {
|
||||
const startOffset = -1;
|
||||
const endOffset = templateElement.tail ? 1 : 2;
|
||||
|
||||
templateElement.start += startOffset;
|
||||
templateElement.end += endOffset;
|
||||
|
||||
if (templateElement.range) {
|
||||
templateElement.range[0] += startOffset;
|
||||
templateElement.range[1] += endOffset;
|
||||
}
|
||||
|
||||
if (templateElement.loc) {
|
||||
templateElement.loc.start.column += startOffset;
|
||||
templateElement.loc.end.column += endOffset;
|
||||
}
|
||||
});
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
parseTopLevel(node) {
|
||||
if (this[STATE].impliedStrict) {
|
||||
this.strict = true;
|
||||
}
|
||||
return super.parseTopLevel(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the default raise method to throw Esprima-style errors.
|
||||
* @param {int} pos The position of the error.
|
||||
* @param {string} message The error message.
|
||||
* @throws {SyntaxError} A syntax error.
|
||||
* @returns {void}
|
||||
*/
|
||||
raise(pos, message) {
|
||||
const loc = Parser.acorn.getLineInfo(this.input, pos);
|
||||
const err = new SyntaxError(message);
|
||||
|
||||
err.index = pos;
|
||||
err.lineNumber = loc.line;
|
||||
err.column = loc.column + 1; // acorn uses 0-based columns
|
||||
throw err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the default raise method to throw Esprima-style errors.
|
||||
* @param {int} pos The position of the error.
|
||||
* @param {string} message The error message.
|
||||
* @throws {SyntaxError} A syntax error.
|
||||
* @returns {void}
|
||||
*/
|
||||
raiseRecoverable(pos, message) {
|
||||
this.raise(pos, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the default unexpected method to throw Esprima-style errors.
|
||||
* @param {int} pos The position of the error.
|
||||
* @throws {SyntaxError} A syntax error.
|
||||
* @returns {void}
|
||||
*/
|
||||
unexpected(pos) {
|
||||
let message = "Unexpected token";
|
||||
|
||||
if (pos !== null && pos !== void 0) {
|
||||
this.pos = pos;
|
||||
|
||||
if (this.options.locations) {
|
||||
while (this.pos < this.lineStart) {
|
||||
this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
|
||||
--this.curLine;
|
||||
}
|
||||
}
|
||||
|
||||
this.nextToken();
|
||||
}
|
||||
|
||||
if (this.end > this.start) {
|
||||
message += ` ${this.input.slice(this.start, this.end)}`;
|
||||
}
|
||||
|
||||
this.raise(this.start, message);
|
||||
}
|
||||
|
||||
/*
|
||||
* Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX
|
||||
* uses regular tt.string without any distinction between this and regular JS
|
||||
* strings. As such, we intercept an attempt to read a JSX string and set a flag
|
||||
* on extra so that when tokens are converted, the next token will be switched
|
||||
* to JSXText via onToken.
|
||||
*/
|
||||
jsx_readString(quote) { // eslint-disable-line camelcase -- required by API
|
||||
const result = super.jsx_readString(quote);
|
||||
|
||||
if (this.type === tokTypes.string) {
|
||||
this[STATE].jsxAttrValueToken = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs last-minute Esprima-specific compatibility checks and fixes.
|
||||
* @param {ASTNode} result The node to check.
|
||||
* @returns {ASTNode} The finished node.
|
||||
*/
|
||||
[ESPRIMA_FINISH_NODE](result) {
|
||||
|
||||
// Acorn doesn't count the opening and closing backticks as part of templates
|
||||
// so we have to adjust ranges/locations appropriately.
|
||||
if (result.type === "TemplateElement") {
|
||||
|
||||
// save template element references to fix start/end later
|
||||
this[STATE].templateElements.push(result);
|
||||
}
|
||||
|
||||
if (result.type.includes("Function") && !result.generator) {
|
||||
result.generator = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
};
|
||||
27
node_modules/@eslint/eslintrc/node_modules/espree/lib/features.js
generated
vendored
Normal file
27
node_modules/@eslint/eslintrc/node_modules/espree/lib/features.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @fileoverview The list of feature flags supported by the parser and their default
|
||||
* settings.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// None!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export default {
|
||||
|
||||
// React JSX parsing
|
||||
jsx: false,
|
||||
|
||||
// allow return statement in global scope
|
||||
globalReturn: false,
|
||||
|
||||
// allow implied strict mode
|
||||
impliedStrict: false
|
||||
};
|
||||
124
node_modules/@eslint/eslintrc/node_modules/espree/lib/options.js
generated
vendored
Normal file
124
node_modules/@eslint/eslintrc/node_modules/espree/lib/options.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* @fileoverview A collection of methods for processing Espree's options.
|
||||
* @author Kai Cataldo
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const SUPPORTED_VERSIONS = [
|
||||
3,
|
||||
5,
|
||||
6, // 2015
|
||||
7, // 2016
|
||||
8, // 2017
|
||||
9, // 2018
|
||||
10, // 2019
|
||||
11, // 2020
|
||||
12, // 2021
|
||||
13, // 2022
|
||||
14, // 2023
|
||||
15, // 2024
|
||||
16 // 2025
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the latest ECMAScript version supported by Espree.
|
||||
* @returns {number} The latest ECMAScript version.
|
||||
*/
|
||||
export function getLatestEcmaVersion() {
|
||||
return SUPPORTED_VERSIONS.at(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of ECMAScript versions supported by Espree.
|
||||
* @returns {number[]} An array containing the supported ECMAScript versions.
|
||||
*/
|
||||
export function getSupportedEcmaVersions() {
|
||||
return [...SUPPORTED_VERSIONS];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize ECMAScript version from the initial config
|
||||
* @param {(number|"latest")} ecmaVersion ECMAScript version from the initial config
|
||||
* @throws {Error} throws an error if the ecmaVersion is invalid.
|
||||
* @returns {number} normalized ECMAScript version
|
||||
*/
|
||||
function normalizeEcmaVersion(ecmaVersion = 5) {
|
||||
|
||||
let version = ecmaVersion === "latest" ? getLatestEcmaVersion() : ecmaVersion;
|
||||
|
||||
if (typeof version !== "number") {
|
||||
throw new Error(`ecmaVersion must be a number or "latest". Received value of type ${typeof ecmaVersion} instead.`);
|
||||
}
|
||||
|
||||
// Calculate ECMAScript edition number from official year version starting with
|
||||
// ES2015, which corresponds with ES6 (or a difference of 2009).
|
||||
if (version >= 2015) {
|
||||
version -= 2009;
|
||||
}
|
||||
|
||||
if (!SUPPORTED_VERSIONS.includes(version)) {
|
||||
throw new Error("Invalid ecmaVersion.");
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize sourceType from the initial config
|
||||
* @param {string} sourceType to normalize
|
||||
* @throws {Error} throw an error if sourceType is invalid
|
||||
* @returns {string} normalized sourceType
|
||||
*/
|
||||
function normalizeSourceType(sourceType = "script") {
|
||||
if (sourceType === "script" || sourceType === "module") {
|
||||
return sourceType;
|
||||
}
|
||||
|
||||
if (sourceType === "commonjs") {
|
||||
return "script";
|
||||
}
|
||||
|
||||
throw new Error("Invalid sourceType.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize parserOptions
|
||||
* @param {Object} options the parser options to normalize
|
||||
* @throws {Error} throw an error if found invalid option.
|
||||
* @returns {Object} normalized options
|
||||
*/
|
||||
export function normalizeOptions(options) {
|
||||
const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
|
||||
const sourceType = normalizeSourceType(options.sourceType);
|
||||
const ranges = options.range === true;
|
||||
const locations = options.loc === true;
|
||||
|
||||
if (ecmaVersion !== 3 && options.allowReserved) {
|
||||
|
||||
// a value of `false` is intentionally allowed here, so a shared config can overwrite it when needed
|
||||
throw new Error("`allowReserved` is only supported when ecmaVersion is 3");
|
||||
}
|
||||
if (typeof options.allowReserved !== "undefined" && typeof options.allowReserved !== "boolean") {
|
||||
throw new Error("`allowReserved`, when present, must be `true` or `false`");
|
||||
}
|
||||
const allowReserved = ecmaVersion === 3 ? (options.allowReserved || "never") : false;
|
||||
const ecmaFeatures = options.ecmaFeatures || {};
|
||||
const allowReturnOutsideFunction = options.sourceType === "commonjs" ||
|
||||
Boolean(ecmaFeatures.globalReturn);
|
||||
|
||||
if (sourceType === "module" && ecmaVersion < 6) {
|
||||
throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
|
||||
}
|
||||
|
||||
return Object.assign({}, options, {
|
||||
ecmaVersion,
|
||||
sourceType,
|
||||
ranges,
|
||||
locations,
|
||||
allowReserved,
|
||||
allowReturnOutsideFunction
|
||||
});
|
||||
}
|
||||
263
node_modules/@eslint/eslintrc/node_modules/espree/lib/token-translator.js
generated
vendored
Normal file
263
node_modules/@eslint/eslintrc/node_modules/espree/lib/token-translator.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
* @fileoverview Translates tokens between Acorn format and Esprima format.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// none!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Esprima Token Types
|
||||
const Token = {
|
||||
Boolean: "Boolean",
|
||||
EOF: "<end>",
|
||||
Identifier: "Identifier",
|
||||
PrivateIdentifier: "PrivateIdentifier",
|
||||
Keyword: "Keyword",
|
||||
Null: "Null",
|
||||
Numeric: "Numeric",
|
||||
Punctuator: "Punctuator",
|
||||
String: "String",
|
||||
RegularExpression: "RegularExpression",
|
||||
Template: "Template",
|
||||
JSXIdentifier: "JSXIdentifier",
|
||||
JSXText: "JSXText"
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts part of a template into an Esprima token.
|
||||
* @param {AcornToken[]} tokens The Acorn tokens representing the template.
|
||||
* @param {string} code The source code.
|
||||
* @returns {EsprimaToken} The Esprima equivalent of the template token.
|
||||
* @private
|
||||
*/
|
||||
function convertTemplatePart(tokens, code) {
|
||||
const firstToken = tokens[0],
|
||||
lastTemplateToken = tokens.at(-1);
|
||||
|
||||
const token = {
|
||||
type: Token.Template,
|
||||
value: code.slice(firstToken.start, lastTemplateToken.end)
|
||||
};
|
||||
|
||||
if (firstToken.loc) {
|
||||
token.loc = {
|
||||
start: firstToken.loc.start,
|
||||
end: lastTemplateToken.loc.end
|
||||
};
|
||||
}
|
||||
|
||||
if (firstToken.range) {
|
||||
token.start = firstToken.range[0];
|
||||
token.end = lastTemplateToken.range[1];
|
||||
token.range = [token.start, token.end];
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains logic to translate Acorn tokens into Esprima tokens.
|
||||
* @param {Object} acornTokTypes The Acorn token types.
|
||||
* @param {string} code The source code Acorn is parsing. This is necessary
|
||||
* to correct the "value" property of some tokens.
|
||||
* @constructor
|
||||
*/
|
||||
function TokenTranslator(acornTokTypes, code) {
|
||||
|
||||
// token types
|
||||
this._acornTokTypes = acornTokTypes;
|
||||
|
||||
// token buffer for templates
|
||||
this._tokens = [];
|
||||
|
||||
// track the last curly brace
|
||||
this._curlyBrace = null;
|
||||
|
||||
// the source code
|
||||
this._code = code;
|
||||
|
||||
}
|
||||
|
||||
TokenTranslator.prototype = {
|
||||
constructor: TokenTranslator,
|
||||
|
||||
/**
|
||||
* Translates a single Esprima token to a single Acorn token. This may be
|
||||
* inaccurate due to how templates are handled differently in Esprima and
|
||||
* Acorn, but should be accurate for all other tokens.
|
||||
* @param {AcornToken} token The Acorn token to translate.
|
||||
* @param {Object} extra Espree extra object.
|
||||
* @returns {EsprimaToken} The Esprima version of the token.
|
||||
*/
|
||||
translate(token, extra) {
|
||||
|
||||
const type = token.type,
|
||||
tt = this._acornTokTypes;
|
||||
|
||||
if (type === tt.name) {
|
||||
token.type = Token.Identifier;
|
||||
|
||||
// TODO: See if this is an Acorn bug
|
||||
if (token.value === "static") {
|
||||
token.type = Token.Keyword;
|
||||
}
|
||||
|
||||
if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) {
|
||||
token.type = Token.Keyword;
|
||||
}
|
||||
|
||||
} else if (type === tt.privateId) {
|
||||
token.type = Token.PrivateIdentifier;
|
||||
|
||||
} else if (type === tt.semi || type === tt.comma ||
|
||||
type === tt.parenL || type === tt.parenR ||
|
||||
type === tt.braceL || type === tt.braceR ||
|
||||
type === tt.dot || type === tt.bracketL ||
|
||||
type === tt.colon || type === tt.question ||
|
||||
type === tt.bracketR || type === tt.ellipsis ||
|
||||
type === tt.arrow || type === tt.jsxTagStart ||
|
||||
type === tt.incDec || type === tt.starstar ||
|
||||
type === tt.jsxTagEnd || type === tt.prefix ||
|
||||
type === tt.questionDot ||
|
||||
(type.binop && !type.keyword) ||
|
||||
type.isAssign) {
|
||||
|
||||
token.type = Token.Punctuator;
|
||||
token.value = this._code.slice(token.start, token.end);
|
||||
} else if (type === tt.jsxName) {
|
||||
token.type = Token.JSXIdentifier;
|
||||
} else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) {
|
||||
token.type = Token.JSXText;
|
||||
} else if (type.keyword) {
|
||||
if (type.keyword === "true" || type.keyword === "false") {
|
||||
token.type = Token.Boolean;
|
||||
} else if (type.keyword === "null") {
|
||||
token.type = Token.Null;
|
||||
} else {
|
||||
token.type = Token.Keyword;
|
||||
}
|
||||
} else if (type === tt.num) {
|
||||
token.type = Token.Numeric;
|
||||
token.value = this._code.slice(token.start, token.end);
|
||||
} else if (type === tt.string) {
|
||||
|
||||
if (extra.jsxAttrValueToken) {
|
||||
extra.jsxAttrValueToken = false;
|
||||
token.type = Token.JSXText;
|
||||
} else {
|
||||
token.type = Token.String;
|
||||
}
|
||||
|
||||
token.value = this._code.slice(token.start, token.end);
|
||||
} else if (type === tt.regexp) {
|
||||
token.type = Token.RegularExpression;
|
||||
const value = token.value;
|
||||
|
||||
token.regex = {
|
||||
flags: value.flags,
|
||||
pattern: value.pattern
|
||||
};
|
||||
token.value = `/${value.pattern}/${value.flags}`;
|
||||
}
|
||||
|
||||
return token;
|
||||
},
|
||||
|
||||
/**
|
||||
* Function to call during Acorn's onToken handler.
|
||||
* @param {AcornToken} token The Acorn token.
|
||||
* @param {Object} extra The Espree extra object.
|
||||
* @returns {void}
|
||||
*/
|
||||
onToken(token, extra) {
|
||||
|
||||
const tt = this._acornTokTypes,
|
||||
tokens = extra.tokens,
|
||||
templateTokens = this._tokens;
|
||||
|
||||
/**
|
||||
* Flushes the buffered template tokens and resets the template
|
||||
* tracking.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
const translateTemplateTokens = () => {
|
||||
tokens.push(convertTemplatePart(this._tokens, this._code));
|
||||
this._tokens = [];
|
||||
};
|
||||
|
||||
if (token.type === tt.eof) {
|
||||
|
||||
// might be one last curlyBrace
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (token.type === tt.backQuote) {
|
||||
|
||||
// if there's already a curly, it's not part of the template
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
this._curlyBrace = null;
|
||||
}
|
||||
|
||||
templateTokens.push(token);
|
||||
|
||||
// it's the end
|
||||
if (templateTokens.length > 1) {
|
||||
translateTemplateTokens();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (token.type === tt.dollarBraceL) {
|
||||
templateTokens.push(token);
|
||||
translateTemplateTokens();
|
||||
return;
|
||||
}
|
||||
if (token.type === tt.braceR) {
|
||||
|
||||
// if there's already a curly, it's not part of the template
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
}
|
||||
|
||||
// store new curly for later
|
||||
this._curlyBrace = token;
|
||||
return;
|
||||
}
|
||||
if (token.type === tt.template || token.type === tt.invalidTemplate) {
|
||||
if (this._curlyBrace) {
|
||||
templateTokens.push(this._curlyBrace);
|
||||
this._curlyBrace = null;
|
||||
}
|
||||
|
||||
templateTokens.push(token);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._curlyBrace) {
|
||||
tokens.push(this.translate(this._curlyBrace, extra));
|
||||
this._curlyBrace = null;
|
||||
}
|
||||
|
||||
tokens.push(this.translate(token, extra));
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export default TokenTranslator;
|
||||
3
node_modules/@eslint/eslintrc/node_modules/espree/lib/version.js
generated
vendored
Normal file
3
node_modules/@eslint/eslintrc/node_modules/espree/lib/version.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
const version = "10.1.0";
|
||||
|
||||
export default version;
|
||||
86
node_modules/@eslint/eslintrc/node_modules/espree/package.json
generated
vendored
Normal file
86
node_modules/@eslint/eslintrc/node_modules/espree/package.json
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "espree",
|
||||
"description": "An Esprima-compatible JavaScript parser built on Acorn",
|
||||
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
||||
"homepage": "https://github.com/eslint/espree",
|
||||
"main": "dist/espree.cjs",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": "./espree.js",
|
||||
"require": "./dist/espree.cjs",
|
||||
"default": "./dist/espree.cjs"
|
||||
},
|
||||
"./dist/espree.cjs"
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"version": "10.1.0",
|
||||
"files": [
|
||||
"lib",
|
||||
"dist/espree.cjs",
|
||||
"espree.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"repository": "eslint/espree",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/espree/issues"
|
||||
},
|
||||
"funding": "https://opencollective.com/eslint",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"acorn": "^8.12.0",
|
||||
"acorn-jsx": "^5.3.2",
|
||||
"eslint-visitor-keys": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^17.1.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.0",
|
||||
"c8": "^7.11.0",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^9.4.0",
|
||||
"eslint-config-eslint": "^11.0.0",
|
||||
"eslint-release": "^3.2.0",
|
||||
"esprima-fb": "^8001.2001.0-dev-harmony-fb",
|
||||
"globals": "^15.1.0",
|
||||
"lint-staged": "^13.2.0",
|
||||
"mocha": "^9.2.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rollup": "^2.41.2",
|
||||
"shelljs": "^0.8.5",
|
||||
"yorkie": "^2.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"ast",
|
||||
"ecmascript",
|
||||
"javascript",
|
||||
"parser",
|
||||
"syntax",
|
||||
"acorn"
|
||||
],
|
||||
"gitHooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c rollup.config.js",
|
||||
"build:debug": "npm run build -- -m",
|
||||
"build:docs": "node tools/sync-docs.js",
|
||||
"build:update-version": "node tools/update-version.js",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"prepublishOnly": "npm run build:update-version && npm run build",
|
||||
"pretest": "npm run build",
|
||||
"release:generate:latest": "eslint-generate-release",
|
||||
"release:generate:alpha": "eslint-generate-prerelease alpha",
|
||||
"release:generate:beta": "eslint-generate-prerelease beta",
|
||||
"release:generate:rc": "eslint-generate-prerelease rc",
|
||||
"release:publish": "eslint-publish-release",
|
||||
"test": "npm-run-all -s test:*",
|
||||
"test:esm": "c8 mocha --color --reporter progress --timeout 30000 'tests/lib/**/*.js'",
|
||||
"test:cjs": "mocha --color --reporter progress --timeout 30000 tests/lib/commonjs.cjs"
|
||||
}
|
||||
}
|
||||
1998
node_modules/@eslint/eslintrc/node_modules/globals/globals.json
generated
vendored
Normal file
1998
node_modules/@eslint/eslintrc/node_modules/globals/globals.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2077
node_modules/@eslint/eslintrc/node_modules/globals/index.d.ts
generated
vendored
Normal file
2077
node_modules/@eslint/eslintrc/node_modules/globals/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/@eslint/eslintrc/node_modules/globals/index.js
generated
vendored
Normal file
2
node_modules/@eslint/eslintrc/node_modules/globals/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
module.exports = require('./globals.json');
|
||||
9
node_modules/@eslint/eslintrc/node_modules/globals/license
generated
vendored
Normal file
9
node_modules/@eslint/eslintrc/node_modules/globals/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
58
node_modules/@eslint/eslintrc/node_modules/globals/package.json
generated
vendored
Normal file
58
node_modules/@eslint/eslintrc/node_modules/globals/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "globals",
|
||||
"version": "14.0.0",
|
||||
"description": "Global identifiers from different JavaScript environments",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/globals",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd",
|
||||
"prepare": "npm run --silent update-types",
|
||||
"update-builtin-globals": "node scripts/get-builtin-globals.mjs",
|
||||
"update-types": "node scripts/generate-types.mjs > index.d.ts"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"globals.json"
|
||||
],
|
||||
"keywords": [
|
||||
"globals",
|
||||
"global",
|
||||
"identifiers",
|
||||
"variables",
|
||||
"vars",
|
||||
"jshint",
|
||||
"eslint",
|
||||
"environments"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"tsd": "^0.30.4",
|
||||
"type-fest": "^4.10.2",
|
||||
"xo": "^0.36.1"
|
||||
},
|
||||
"xo": {
|
||||
"ignores": [
|
||||
"get-browser-globals.js"
|
||||
],
|
||||
"rules": {
|
||||
"node/no-unsupported-features/es-syntax": "off"
|
||||
}
|
||||
},
|
||||
"tsd": {
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true
|
||||
}
|
||||
}
|
||||
}
|
||||
44
node_modules/@eslint/eslintrc/node_modules/globals/readme.md
generated
vendored
Normal file
44
node_modules/@eslint/eslintrc/node_modules/globals/readme.md
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# globals
|
||||
|
||||
> Global identifiers from different JavaScript environments
|
||||
|
||||
It's just a [JSON file](globals.json), so use it in any environment.
|
||||
|
||||
This package is used by ESLint.
|
||||
|
||||
**This package [no longer accepts](https://github.com/sindresorhus/globals/issues/82) new environments. If you need it for ESLint, just [create a plugin](http://eslint.org/docs/developer-guide/working-with-plugins#environments-in-plugins).**
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install globals
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const globals = require('globals');
|
||||
|
||||
console.log(globals.browser);
|
||||
/*
|
||||
{
|
||||
addEventListener: false,
|
||||
applicationCache: false,
|
||||
ArrayBuffer: false,
|
||||
atob: false,
|
||||
…
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
Each global is given a value of `true` or `false`. A value of `true` indicates that the variable may be overwritten. A value of `false` indicates that the variable should be considered read-only. This information is used by static analysis tools to flag incorrect behavior. We assume all variables should be `false` unless we hear otherwise.
|
||||
|
||||
For Node.js this package provides two sets of globals:
|
||||
|
||||
- `globals.nodeBuiltin`: Globals available to all code running in Node.js.
|
||||
These will usually be available as properties on the `global` object and include `process`, `Buffer`, but not CommonJS arguments like `require`.
|
||||
See: https://nodejs.org/api/globals.html
|
||||
- `globals.node`: A combination of the globals from `nodeBuiltin` plus all CommonJS arguments ("CommonJS module scope").
|
||||
See: https://nodejs.org/api/modules.html#modules_the_module_scope
|
||||
|
||||
When analyzing code that is known to run outside of a CommonJS wrapper, for example, JavaScript modules, `nodeBuiltin` can find accidental CommonJS references.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user