Save current BZZZ config-ui state before CHORUS branding update

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-08-19 00:19:00 +10:00
parent 6a6a49b7b1
commit c177363a19
16410 changed files with 1789161 additions and 230 deletions

View File

@@ -0,0 +1,22 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('decoupled-local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
require('decoupled-local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
module.exports = {
extends: [
'decoupled-local-node-rig/profiles/default/includes/eslint/profile/node',
'decoupled-local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals',
'decoupled-local-node-rig/profiles/default/includes/eslint/mixins/tsdoc'
],
parserOptions: { tsconfigRootDir: __dirname },
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'no-console': 'off'
}
}
]
};

View File

@@ -0,0 +1,462 @@
{
"name": "@rushstack/eslint-patch",
"entries": [
{
"version": "1.12.0",
"tag": "@rushstack/eslint-patch_v1.12.0",
"date": "Thu, 26 Jun 2025 18:57:04 GMT",
"comments": {
"minor": [
{
"comment": "Update for compatibility with ESLint 9"
}
]
}
},
{
"version": "1.11.0",
"tag": "@rushstack/eslint-patch_v1.11.0",
"date": "Tue, 11 Mar 2025 02:12:33 GMT",
"comments": {
"minor": [
{
"comment": "Bump the `@typescript-eslint/*` packages to add support for TypeScript 5.8."
}
]
}
},
{
"version": "1.10.5",
"tag": "@rushstack/eslint-patch_v1.10.5",
"date": "Tue, 07 Jan 2025 16:11:06 GMT",
"comments": {
"patch": [
{
"comment": "Fix a performance issue when locating \".eslint-bulk-suppressions.json\"."
}
]
}
},
{
"version": "1.10.4",
"tag": "@rushstack/eslint-patch_v1.10.4",
"date": "Sat, 27 Jul 2024 00:10:27 GMT",
"comments": {
"patch": [
{
"comment": "Include CHANGELOG.md in published releases again"
}
]
}
},
{
"version": "1.10.3",
"tag": "@rushstack/eslint-patch_v1.10.3",
"date": "Fri, 17 May 2024 00:10:40 GMT",
"comments": {
"patch": [
{
"comment": "[eslint-patch] Allow use of ESLint v9"
}
]
}
},
{
"version": "1.10.2",
"tag": "@rushstack/eslint-patch_v1.10.2",
"date": "Wed, 10 Apr 2024 21:59:39 GMT",
"comments": {
"patch": [
{
"comment": "Bump maximum supported ESLint version for the bulk-suppressions tool to `8.57.0`."
}
]
}
},
{
"version": "1.10.1",
"tag": "@rushstack/eslint-patch_v1.10.1",
"date": "Fri, 29 Mar 2024 05:46:41 GMT",
"comments": {
"patch": [
{
"comment": "Fix an issue where the `eslint-bulk prune` command would crash if a bulk suppressions file exists that speicifies no suppressions."
},
{
"comment": "Exit with success under normal conditions."
}
]
}
},
{
"version": "1.10.0",
"tag": "@rushstack/eslint-patch_v1.10.0",
"date": "Thu, 28 Mar 2024 18:11:12 GMT",
"comments": {
"patch": [
{
"comment": "Fix an issue with running `eslint-bulk prune` in a project with suppressions that refer to deleted files."
}
],
"minor": [
{
"comment": "Delete the `.eslint-bulk-suppressions.json` file during pruning if all suppressions have been eliminated."
}
]
}
},
{
"version": "1.9.0",
"tag": "@rushstack/eslint-patch_v1.9.0",
"date": "Wed, 27 Mar 2024 19:47:21 GMT",
"comments": {
"minor": [
{
"comment": "Fix an issue where `eslint-bulk prune` does not work if there are no files to lint in the project root."
}
]
}
},
{
"version": "1.8.0",
"tag": "@rushstack/eslint-patch_v1.8.0",
"date": "Wed, 20 Mar 2024 02:09:14 GMT",
"comments": {
"minor": [
{
"comment": "Refactor the bulk-suppressions feature to fix some performance issues."
}
],
"patch": [
{
"comment": "Fix an issue where linting issues that were already suppressed via suppression comments were recorded in the bulk suppressions list."
}
]
}
},
{
"version": "1.7.2",
"tag": "@rushstack/eslint-patch_v1.7.2",
"date": "Thu, 25 Jan 2024 23:03:57 GMT",
"comments": {
"patch": [
{
"comment": "Some minor documentation updates"
}
]
}
},
{
"version": "1.7.1",
"tag": "@rushstack/eslint-patch_v1.7.1",
"date": "Wed, 24 Jan 2024 07:38:34 GMT",
"comments": {
"patch": [
{
"comment": "Update documentation"
}
]
}
},
{
"version": "1.7.0",
"tag": "@rushstack/eslint-patch_v1.7.0",
"date": "Tue, 16 Jan 2024 18:30:10 GMT",
"comments": {
"minor": [
{
"comment": "Add support for TypeScript 5.3 with @typescript-eslint 6.19.x"
}
]
}
},
{
"version": "1.6.1",
"tag": "@rushstack/eslint-patch_v1.6.1",
"date": "Fri, 15 Dec 2023 01:10:06 GMT",
"comments": {
"patch": [
{
"comment": "Fix bulk suppression patch's eslintrc detection in polyrepos"
}
]
}
},
{
"version": "1.6.0",
"tag": "@rushstack/eslint-patch_v1.6.0",
"date": "Wed, 22 Nov 2023 01:45:18 GMT",
"comments": {
"minor": [
{
"comment": "Add an experimental new feature for ESLint bulk suppressions; for details see GitHub #4303"
}
]
}
},
{
"version": "1.5.1",
"tag": "@rushstack/eslint-patch_v1.5.1",
"date": "Sun, 01 Oct 2023 02:56:29 GMT",
"comments": {
"patch": [
{
"comment": "Fix patch compatibility with ESLint 7 for versions matching <7.12.0"
}
]
}
},
{
"version": "1.5.0",
"tag": "@rushstack/eslint-patch_v1.5.0",
"date": "Tue, 26 Sep 2023 09:30:33 GMT",
"comments": {
"minor": [
{
"comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix"
}
]
}
},
{
"version": "1.4.0",
"tag": "@rushstack/eslint-patch_v1.4.0",
"date": "Fri, 15 Sep 2023 00:36:58 GMT",
"comments": {
"minor": [
{
"comment": "Update @types/node from 14 to 18"
}
]
}
},
{
"version": "1.3.3",
"tag": "@rushstack/eslint-patch_v1.3.3",
"date": "Tue, 08 Aug 2023 07:10:39 GMT",
"comments": {
"patch": [
{
"comment": "Fix patching for running eslint via eslint/use-at-your-own-risk, which VS Code's eslint extension does when enabling flat config support"
}
]
}
},
{
"version": "1.3.2",
"tag": "@rushstack/eslint-patch_v1.3.2",
"date": "Thu, 15 Jun 2023 00:21:01 GMT",
"comments": {
"patch": [
{
"comment": "[eslint-patch] add invalid importer path test to ESLint 7.x || 8.x block"
}
]
}
},
{
"version": "1.3.1",
"tag": "@rushstack/eslint-patch_v1.3.1",
"date": "Wed, 07 Jun 2023 22:45:16 GMT",
"comments": {
"patch": [
{
"comment": "Add test for invalid importer path to fallback to relative path when loading eslint 6 plugins"
}
]
}
},
{
"version": "1.3.0",
"tag": "@rushstack/eslint-patch_v1.3.0",
"date": "Mon, 22 May 2023 06:34:32 GMT",
"comments": {
"minor": [
{
"comment": "Upgrade the @typescript-eslint/* dependencies to ~5.59.2"
}
]
}
},
{
"version": "1.2.0",
"tag": "@rushstack/eslint-patch_v1.2.0",
"date": "Thu, 15 Sep 2022 00:18:51 GMT",
"comments": {
"minor": [
{
"comment": "Use original resolver if patched resolver fails."
}
]
}
},
{
"version": "1.1.4",
"tag": "@rushstack/eslint-patch_v1.1.4",
"date": "Tue, 28 Jun 2022 00:23:32 GMT",
"comments": {
"patch": [
{
"comment": "Update the README to mention support for ESLint 8."
}
]
}
},
{
"version": "1.1.3",
"tag": "@rushstack/eslint-patch_v1.1.3",
"date": "Fri, 15 Apr 2022 00:12:36 GMT",
"comments": {
"patch": [
{
"comment": "Fix an issue where tools could not determine the module type as CommonJS"
}
]
}
},
{
"version": "1.1.2",
"tag": "@rushstack/eslint-patch_v1.1.2",
"date": "Sat, 09 Apr 2022 02:24:26 GMT",
"comments": {
"patch": [
{
"comment": "Rename the \"master\" branch to \"main\"."
}
]
}
},
{
"version": "1.1.1",
"tag": "@rushstack/eslint-patch_v1.1.1",
"date": "Tue, 15 Mar 2022 19:15:53 GMT",
"comments": {
"patch": [
{
"comment": "Fix the path in the package.json \"directory\" field."
}
]
}
},
{
"version": "1.1.0",
"tag": "@rushstack/eslint-patch_v1.1.0",
"date": "Fri, 05 Nov 2021 15:09:18 GMT",
"comments": {
"minor": [
{
"comment": "feat(eslint-patch): Find patch targets independently of disk layout"
}
]
}
},
{
"version": "1.0.9",
"tag": "@rushstack/eslint-patch_v1.0.9",
"date": "Wed, 27 Oct 2021 00:08:15 GMT",
"comments": {
"patch": [
{
"comment": "Update the package.json repository field to include the directory property."
}
]
}
},
{
"version": "1.0.8",
"tag": "@rushstack/eslint-patch_v1.0.8",
"date": "Wed, 13 Oct 2021 15:09:54 GMT",
"comments": {
"patch": [
{
"comment": "Add support for ESLint 8.0.0"
}
]
}
},
{
"version": "1.0.7",
"tag": "@rushstack/eslint-patch_v1.0.7",
"date": "Thu, 23 Sep 2021 00:10:40 GMT",
"comments": {
"patch": [
{
"comment": "Upgrade the `@types/node` dependency to version to version 12."
}
]
}
},
{
"version": "1.0.6",
"tag": "@rushstack/eslint-patch_v1.0.6",
"date": "Fri, 30 Oct 2020 00:10:14 GMT",
"comments": {
"patch": [
{
"comment": "Update the \"modern-module-resolution\" patch to support ESLint 7.8.0 and newer"
}
]
}
},
{
"version": "1.0.5",
"tag": "@rushstack/eslint-patch_v1.0.5",
"date": "Wed, 30 Sep 2020 18:39:17 GMT",
"comments": {
"patch": [
{
"comment": "Update to build with @rushstack/heft-node-rig"
}
]
}
},
{
"version": "1.0.4",
"tag": "@rushstack/eslint-patch_v1.0.4",
"date": "Wed, 30 Sep 2020 06:53:53 GMT",
"comments": {
"patch": [
{
"comment": "Update README.md"
}
]
}
},
{
"version": "1.0.3",
"tag": "@rushstack/eslint-patch_v1.0.3",
"date": "Wed, 12 Aug 2020 00:10:05 GMT",
"comments": {
"patch": [
{
"comment": "Updated project to build with Heft"
}
]
}
},
{
"version": "1.0.2",
"tag": "@rushstack/eslint-patch_v1.0.2",
"date": "Wed, 24 Jun 2020 09:50:48 GMT",
"comments": {
"patch": [
{
"comment": "Fix an issue with the published file set"
}
]
}
},
{
"version": "1.0.1",
"tag": "@rushstack/eslint-patch_v1.0.1",
"date": "Wed, 24 Jun 2020 09:04:28 GMT",
"comments": {
"patch": [
{
"comment": "Initial release"
}
]
}
}
]
}

View File

@@ -0,0 +1,272 @@
# Change Log - @rushstack/eslint-patch
This log was last generated on Thu, 26 Jun 2025 18:57:04 GMT and should not be manually modified.
## 1.12.0
Thu, 26 Jun 2025 18:57:04 GMT
### Minor changes
- Update for compatibility with ESLint 9
## 1.11.0
Tue, 11 Mar 2025 02:12:33 GMT
### Minor changes
- Bump the `@typescript-eslint/*` packages to add support for TypeScript 5.8.
## 1.10.5
Tue, 07 Jan 2025 16:11:06 GMT
### Patches
- Fix a performance issue when locating ".eslint-bulk-suppressions.json".
## 1.10.4
Sat, 27 Jul 2024 00:10:27 GMT
### Patches
- Include CHANGELOG.md in published releases again
## 1.10.3
Fri, 17 May 2024 00:10:40 GMT
### Patches
- [eslint-patch] Allow use of ESLint v9
## 1.10.2
Wed, 10 Apr 2024 21:59:39 GMT
### Patches
- Bump maximum supported ESLint version for the bulk-suppressions tool to `8.57.0`.
## 1.10.1
Fri, 29 Mar 2024 05:46:41 GMT
### Patches
- Fix an issue where the `eslint-bulk prune` command would crash if a bulk suppressions file exists that speicifies no suppressions.
- Exit with success under normal conditions.
## 1.10.0
Thu, 28 Mar 2024 18:11:12 GMT
### Minor changes
- Delete the `.eslint-bulk-suppressions.json` file during pruning if all suppressions have been eliminated.
### Patches
- Fix an issue with running `eslint-bulk prune` in a project with suppressions that refer to deleted files.
## 1.9.0
Wed, 27 Mar 2024 19:47:21 GMT
### Minor changes
- Fix an issue where `eslint-bulk prune` does not work if there are no files to lint in the project root.
## 1.8.0
Wed, 20 Mar 2024 02:09:14 GMT
### Minor changes
- Refactor the bulk-suppressions feature to fix some performance issues.
### Patches
- Fix an issue where linting issues that were already suppressed via suppression comments were recorded in the bulk suppressions list.
## 1.7.2
Thu, 25 Jan 2024 23:03:57 GMT
### Patches
- Some minor documentation updates
## 1.7.1
Wed, 24 Jan 2024 07:38:34 GMT
### Patches
- Update documentation
## 1.7.0
Tue, 16 Jan 2024 18:30:10 GMT
### Minor changes
- Add support for TypeScript 5.3 with @typescript-eslint 6.19.x
## 1.6.1
Fri, 15 Dec 2023 01:10:06 GMT
### Patches
- Fix bulk suppression patch's eslintrc detection in polyrepos
## 1.6.0
Wed, 22 Nov 2023 01:45:18 GMT
### Minor changes
- Add an experimental new feature for ESLint bulk suppressions; for details see GitHub #4303
## 1.5.1
Sun, 01 Oct 2023 02:56:29 GMT
### Patches
- Fix patch compatibility with ESLint 7 for versions matching <7.12.0
## 1.5.0
Tue, 26 Sep 2023 09:30:33 GMT
### Minor changes
- Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the "eslint-config-" prefix
## 1.4.0
Fri, 15 Sep 2023 00:36:58 GMT
### Minor changes
- Update @types/node from 14 to 18
## 1.3.3
Tue, 08 Aug 2023 07:10:39 GMT
### Patches
- Fix patching for running eslint via eslint/use-at-your-own-risk, which VS Code's eslint extension does when enabling flat config support
## 1.3.2
Thu, 15 Jun 2023 00:21:01 GMT
### Patches
- [eslint-patch] add invalid importer path test to ESLint 7.x || 8.x block
## 1.3.1
Wed, 07 Jun 2023 22:45:16 GMT
### Patches
- Add test for invalid importer path to fallback to relative path when loading eslint 6 plugins
## 1.3.0
Mon, 22 May 2023 06:34:32 GMT
### Minor changes
- Upgrade the @typescript-eslint/* dependencies to ~5.59.2
## 1.2.0
Thu, 15 Sep 2022 00:18:51 GMT
### Minor changes
- Use original resolver if patched resolver fails.
## 1.1.4
Tue, 28 Jun 2022 00:23:32 GMT
### Patches
- Update the README to mention support for ESLint 8.
## 1.1.3
Fri, 15 Apr 2022 00:12:36 GMT
### Patches
- Fix an issue where tools could not determine the module type as CommonJS
## 1.1.2
Sat, 09 Apr 2022 02:24:26 GMT
### Patches
- Rename the "master" branch to "main".
## 1.1.1
Tue, 15 Mar 2022 19:15:53 GMT
### Patches
- Fix the path in the package.json "directory" field.
## 1.1.0
Fri, 05 Nov 2021 15:09:18 GMT
### Minor changes
- feat(eslint-patch): Find patch targets independently of disk layout
## 1.0.9
Wed, 27 Oct 2021 00:08:15 GMT
### Patches
- Update the package.json repository field to include the directory property.
## 1.0.8
Wed, 13 Oct 2021 15:09:54 GMT
### Patches
- Add support for ESLint 8.0.0
## 1.0.7
Thu, 23 Sep 2021 00:10:40 GMT
### Patches
- Upgrade the `@types/node` dependency to version to version 12.
## 1.0.6
Fri, 30 Oct 2020 00:10:14 GMT
### Patches
- Update the "modern-module-resolution" patch to support ESLint 7.8.0 and newer
## 1.0.5
Wed, 30 Sep 2020 18:39:17 GMT
### Patches
- Update to build with @rushstack/heft-node-rig
## 1.0.4
Wed, 30 Sep 2020 06:53:53 GMT
### Patches
- Update README.md
## 1.0.3
Wed, 12 Aug 2020 00:10:05 GMT
### Patches
- Updated project to build with Heft
## 1.0.2
Wed, 24 Jun 2020 09:50:48 GMT
### Patches
- Fix an issue with the published file set
## 1.0.1
Wed, 24 Jun 2020 09:04:28 GMT
### Patches
- Initial release

View File

@@ -0,0 +1,24 @@
@rushstack/eslint-patch
Copyright (c) Microsoft Corporation. All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,252 @@
# @rushstack/eslint-patch
Enhance [ESLint](https://eslint.org/) with better support for large scale monorepos!
This is a runtime patch that enables new/experimental features for ESLint. It operates as a "monkey patch"
that gets loaded with **.eslintrc.js** and modifies the ESLint engine in memory. This approach works
with your existing ESLint version (no need to install a forked ESLint), and is fully interoperable with
companion tools such as the ESLint extensions for VS Code and WebStorm.
This package provides several independently loadable features:
- **eslint-bulk-suppressions**: enables you to roll out new lint rules in your monorepo without having to
clutter up source files with thousands of machine-generated `// eslint-ignore-next-line` directives.
Instead, the "bulk suppressions" for legacy violations are managed in a separate file called
**.eslint-bulk-suppressions.json**.
- **modern-module-resolution**: allows an ESLint config package to provide plugin dependencies, avoiding the
problem where hundreds of projects in a monorepo need to copy+paste the same `"devDependencies"` in
every **package.json** file.
> **NOTE:** ESLint 8.21.0 has now introduced a new `ESLINT_USE_FLAT_CONFIG` mode that may reduce the need
for the `modern-module-resolution` patch.
- **custom-config-package-names**: enables [rig packages](https://heft.rushstack.io/pages/intro/rig_packages/)
to provide shareable configs for ESLint, by removing the requirement that `eslint-config` must appear in
the NPM package name.
Contributions welcome! If you have more ideas for experimental ESLint enhancements that might benefit
large scale monorepos, consider adding them to this patch.
# eslint-bulk-suppressions feature
<!-- ## is correct here, but ### looks better in NPM's rendering -->
### What it does
As your monorepo evolves and grows, there's an ongoing need to expand and improve lint rules. But whenever a
new rule is enabled, there may be hundreds or thousands of "legacy violations" in existing source files.
How to handle that? We could fix the old code, but that's often prohibitively expensive and may even cause
regressions. We could disable the rule for those projects or files, but we want new code to follow the rule.
An effective solution is to inject thousands of `// eslint-ignore-next-line` lines, but these "bulk suppressions"
have an unintended side effect: It normalizes the practice of suppressing lint rules. If people get used to
seeing `// eslint-ignore-next-line` everywhere, nobody will notice when humans suppress the rules for new code.
That would undermine the mission of establishing better code standards.
The `eslint-bulk-suppressions` feature introduces a way to store machine-generated suppressions in a separate
file **.eslint-bulk-suppressions.json** which can even be protected using `CODEOWNERS` policies, since that file
will generally only change when new lint rules are introduced, or in occasional circumstances when existing files
are being moved or renamed. In this way `// eslint-ignore-next-line` remains a directive written by humans
and hopefully rarely needed.
### Why it's a patch
As with `modern-module-resolution`, our hope is for this feature to eventually be incorporated as an official
feature of ESLint. Starting out as an unofficial patch allows faster iteration and community feedback.
### How to use it
1. Add `@rushstack/eslint-patch` as a dependency of your project:
```bash
cd your-project
npm install --save-dev @rushstack/eslint-patch
```
2. Globally install the [`@rushstack/eslint-bulk`](https://www.npmjs.com/package/@rushstack/eslint-bulk)
command line interface (CLI) package. For example:
```bash
npm install --global @rushstack/eslint-bulk
```
This installs the `eslint-bulk` shell command for managing the **.eslint-bulk-suppressions.json** files.
With it you can generate new suppressions as well as "prune" old suppressions that are no longer needed.
3. Load the patch by adding the following `require()` statement as the first line of
your **.eslintrc.js** file. For example:
**.eslintrc.js**
```js
require("@rushstack/eslint-patch/eslint-bulk-suppressions"); // 👈 add this line
module.exports = {
rules: {
rule1: 'error',
rule2: 'warning'
},
parserOptions: { tsconfigRootDir: __dirname }
};
```
Typical workflow:
1. Checkout your `main` branch, which is in a clean state where ESLint reports no violations.
2. Update your configuration to enable the latest lint rules; ESLint now reports thousands of legacy violations.
3. Run `eslint-bulk suppress --all ./src` to update **.eslint-bulk-suppressions.json.**
4. ESLint now no longer reports violations, so commit the results to Git and merge your pull request.
5. Over time, engineers may improve some of the suppressed code, in which case the associated suppressions are no longer needed.
6. Run `eslint-bulk prune` periodically to find and remove unnecessary suppressions from **.eslint-bulk-suppressions.json**, ensuring that new violations will now get caught in those scopes.
### "eslint-bulk suppress" command
```bash
eslint-bulk suppress --rule NAME1 [--rule NAME2...] PATH1 [PATH2...]
eslint-bulk suppress --all PATH1 [PATH2...]
```
Use this command to automatically generate bulk suppressions for the specified lint rules and file paths.
The path argument is a [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) with the same syntax
as path arguments for the `eslint` command.
### "eslint-bulk prune" command
Use this command to automatically delete all unnecessary suppression entries in all
**.eslint-bulk-suppressions.json** files under the current working directory.
```bash
eslint-bulk prune
```
### Implementation notes
The `eslint-bulk` command is a thin wrapper whose behavior is actually provided by the patch itself.
In this way, if your monorepo contains projects using different versions of this package, the same globally
installed `eslint-bulk` command can be used under any project folder, and it will always invoke the correct
version of the engine compatible with that project. Because the patch is loaded by ESLint, the `eslint-bulk`
command must be invoked in a project folder that contains an **.eslintrc.js** configuration with correctly
installed **package.json** dependencies.
Here's an example of the bulk suppressions file content:
**.eslint-bulk-suppressions.json**
```js
{
"suppressions": [
{
"rule": "no-var",
"file": "./src/your-file.ts",
"scopeId": ".ExampleClass.exampleMethod"
}
]
}
```
The `rule` field is the ESLint rule name. The `file` field is the source file path, relative to the **eslintrc.js** file. The `scopeId` is a special string built from the names of containing structures. (For implementation details, take a look at the [calculateScopeId()](https://github.com/microsoft/rushstack/blob/e95c51088341f01516ee5a7639d57c3f6dce8772/eslint/eslint-patch/src/eslint-bulk-suppressions/bulk-suppressions-patch.ts#L52) function.) The `scopeId` identifies a region of code where the rule should be suppressed, while being reasonably stable across edits of the source file.
# modern-module-resolution feature
### What it does
This patch is a workaround for a longstanding [ESLint feature request](https://github.com/eslint/eslint/issues/3458)
that would allow a shareable ESLint config to bring along its own plugins, rather than imposing peer dependencies
on every consumer of the config. In a monorepo scenario, this enables your lint setup to be consolidated in a
single NPM package. Doing so greatly reduces the copy+pasting and version management for all the other projects
that use your standard lint rule set, but don't want to be bothered with the details.
> **NOTE:** ESLint 8.21.0 has now introduced a new `ESLINT_USE_FLAT_CONFIG` mode that may reduce the need
> for this patch.
### Why it's a patch
We initially proposed this feature in a pull request for the official ESLint back in 2019, however the
maintainers preferred to implement a more comprehensive overhaul of the ESLint config engine. It ultimately
shipped with the experimental new `ESLINT_USE_FLAT_CONFIG` mode (still opt-in as of ESLint 8).
While waiting for that, Rush Stack's `modern-module-resolution` patch provided a reliable interim solution.
We will continue to maintain this patch as long as it is being widely used, but we encourage you to check out
`ESLINT_USE_FLAT_CONFIG` and see if it meets your needs.
### How to use it
1. Add `@rushstack/eslint-patch` as a dependency of your project:
```bash
cd your-project
npm install --save-dev @rushstack/eslint-patch
```
2. Add a `require()` call to the to top of the **.eslintrc.js** file for each project that depends
on your shareable ESLint config, for example:
**.eslintrc.js**
```ts
require("@rushstack/eslint-patch/modern-module-resolution"); // 👈 add this line
// Add your "extends" boilerplate here, for example:
module.exports = {
extends: ['@your-company/eslint-config'],
parserOptions: { tsconfigRootDir: __dirname }
};
```
With this change, the local project no longer needs any ESLint plugins in its **package.json** file.
Instead, the hypothetical `@your-company/eslint-config` NPM package would declare the plugins as its
own dependencies.
This patch works by modifying the ESLint engine so that its module resolver will load relative to the folder of
the referencing config file, rather than the project folder. The patch is compatible with ESLint 6, 7, and 8.
It also works with any editor extensions that load ESLint as a library.
For an even leaner setup, `@your-company/eslint-config` can provide the patches as its own dependency.
See [@rushstack/eslint-config](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-config/patch/modern-module-resolution.js) for a real world example.
# custom-config-package-names feature
### What it does
Load the `custom-config-package-names` patch to remove ESLint's
[naming requirement](https://eslint.org/docs/latest/extend/shareable-configs)
that `eslint-config` must be part of the NPM package name for shareable configs.
This is useful because Rush Stack's [rig package](https://heft.rushstack.io/pages/intro/rig_packages/)
specification defines a way for many different tooling configurations and dependencies to be shared
via a single NPM package, for example
[`@rushstack/heft-web-rig`](https://www.npmjs.com/package/@rushstack/heft-web-rig).
Rigs avoid a lot of copy+pasting of dependencies in a large scale monorepo.
Rig packages always include the `-rig` suffix in their name. It doesn't make sense to enforce
that `eslint-config` should also appear in the name of a package that includes shareable configs
for many other tools besides ESLint.
### How to use it
Continuing the example above, to load this patch you would add a second line to your config file:
**.eslintrc.js**
```ts
require("@rushstack/eslint-patch/modern-module-resolution");
require("@rushstack/eslint-patch/custom-config-package-names"); // 👈 add this line
// Add your "extends" boilerplate here, for example:
module.exports = {
extends: [
'@your-company/build-rig/profile/default/includes/eslint/node' // Notice the package name does not start with "eslint-config-"
],
parserOptions: { tsconfigRootDir: __dirname }
};
```
# Links
- [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-patch/CHANGELOG.md) - Find
out what's new in the latest version
- [`@rushstack/eslint-bulk`](https://www.npmjs.com/package/@rushstack/eslint-bulk) CLI package
`@rushstack/eslint-patch` is part of the [Rush Stack](https://rushstack.io/) family of projects.

View File

@@ -0,0 +1 @@
require('./lib/custom-config-package-names');

View File

@@ -0,0 +1 @@
require('./lib/eslint-bulk-suppressions');

View File

@@ -0,0 +1,13 @@
declare const isModuleResolutionError: (ex: unknown) => boolean;
declare let eslintFolder: string | undefined;
export declare const eslintPackageVersion: string;
declare const ESLINT_MAJOR_VERSION: number;
declare let configArrayFactory: any;
declare let ModuleResolver: {
resolve: any;
};
declare let Naming: {
normalizePackageName: any;
};
export { eslintFolder, configArrayFactory, ModuleResolver, Naming, ESLINT_MAJOR_VERSION, isModuleResolutionError };
//# sourceMappingURL=_patch-base.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"_patch-base.d.ts","sourceRoot":"","sources":["../src/_patch-base.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,uBAAuB,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OACyD,CAAC;AAuE1G,QAAA,IAAI,YAAY,EAAE,MAAM,GAAG,SAAqB,CAAC;AAqNjD,eAAO,MAAM,oBAAoB,EAAE,MAAoC,CAAC;AACxE,QAAA,MAAM,oBAAoB,EAAE,MAA2C,CAAC;AAiBxE,QAAA,IAAI,kBAAkB,EAAE,GAAG,CAAC;AAQ5B,QAAA,IAAI,cAAc,EAAE;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC;AAErC,QAAA,IAAI,MAAM,EAAE;IAAE,oBAAoB,EAAE,GAAG,CAAA;CAAE,CAAC;AAS1C,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,MAAM,EACN,oBAAoB,EACpB,uBAAuB,EACxB,CAAC"}

View File

@@ -0,0 +1,286 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isModuleResolutionError = exports.ESLINT_MAJOR_VERSION = exports.Naming = exports.ModuleResolver = exports.configArrayFactory = exports.eslintFolder = exports.eslintPackageVersion = void 0;
// This is a workaround for https://github.com/eslint/eslint/issues/3458
//
// To correct how ESLint searches for plugin packages, add this line to the top of your project's .eslintrc.js file:
//
// require("@rushstack/eslint-patch/modern-module-resolution");
//
const path_1 = __importDefault(require("path"));
const isModuleResolutionError = (ex) => typeof ex === 'object' && !!ex && 'code' in ex && ex.code === 'MODULE_NOT_FOUND';
exports.isModuleResolutionError = isModuleResolutionError;
const FLAT_CONFIG_REGEX = /eslint\.config\.(cjs|mjs|js)$/i;
// Ex:
// at async ESLint.lintFiles (C:\\path\\to\\\\eslint\\lib\\eslint\\eslint.js:720:21)
const NODE_STACK_REGEX = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?)(?::(\d+)| (\d+))(?::(\d+))?\)?\s*$/i;
function parseNodeStack(stack) {
const stackTraceMatch = NODE_STACK_REGEX.exec(stack);
if (!stackTraceMatch) {
return undefined;
}
return {
file: stackTraceMatch[2],
method: stackTraceMatch[1],
lineNumber: parseInt(stackTraceMatch[3], 10),
column: stackTraceMatch[4] ? parseInt(stackTraceMatch[4], 10) : undefined
};
}
function getStackTrace() {
const stackObj = {};
const originalStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = Infinity;
Error.captureStackTrace(stackObj, getStackTrace);
Error.stackTraceLimit = originalStackTraceLimit;
if (!stackObj.stack) {
throw new Error('Unable to capture stack trace');
}
const { stack } = stackObj;
const stackLines = stack.split('\n');
const frames = [];
for (const line of stackLines) {
const frame = parseNodeStack(line);
if (frame) {
frames.push(frame);
}
}
return frames;
}
// Module path for eslintrc.cjs
// Example: ".../@eslint/eslintrc/dist/eslintrc.cjs"
let eslintrcBundlePath = undefined;
// Module path for config-array-factory.js
// Example: ".../@eslint/eslintrc/lib/config-array-factory"
let configArrayFactoryPath = undefined;
// Module path for relative-module-resolver.js
// Example: ".../@eslint/eslintrc/lib/shared/relative-module-resolver"
let moduleResolverPath = undefined;
// Module path for naming.js
// Example: ".../@eslint/eslintrc/lib/shared/naming"
let namingPath = undefined;
// Folder path where ESLint's package.json can be found
// Example: ".../node_modules/eslint"
let eslintFolder = undefined;
exports.eslintFolder = eslintFolder;
// Probe for the ESLint >=9.0.0 flat config layout:
for (let currentModule = module;;) {
if (FLAT_CONFIG_REGEX.test(currentModule.filename)) {
// Obtain the stack trace of the current module, since the
// parent module of a flat config is undefined. From the
// stack trace, we can find the ESLint folder.
const stackTrace = getStackTrace();
const targetFrame = stackTrace.find((frame) => frame.file && frame.file.endsWith('eslint.js'));
if (targetFrame) {
// Walk up the path and continuously attempt to resolve the ESLint folder
let currentPath = targetFrame.file;
while (currentPath) {
const potentialPath = path_1.default.dirname(currentPath);
if (potentialPath === currentPath) {
break;
}
currentPath = potentialPath;
try {
exports.eslintFolder = eslintFolder = path_1.default.dirname(require.resolve('eslint/package.json', { paths: [currentPath] }));
break;
}
catch (ex) {
if (!isModuleResolutionError(ex)) {
throw ex;
}
}
}
}
if (eslintFolder) {
const eslintrcFolderPath = path_1.default.dirname(require.resolve('@eslint/eslintrc/package.json', { paths: [eslintFolder] }));
eslintrcBundlePath = path_1.default.join(eslintrcFolderPath, 'dist/eslintrc.cjs');
}
break;
}
if (!currentModule.parent) {
break;
}
currentModule = currentModule.parent;
}
if (!eslintFolder) {
// Probe for the ESLint >=8.0.0 layout:
for (let currentModule = module;;) {
if (!eslintrcBundlePath) {
if (currentModule.filename.endsWith('eslintrc.cjs')) {
// For ESLint >=8.0.0, all @eslint/eslintrc code is bundled at this path:
// .../@eslint/eslintrc/dist/eslintrc.cjs
try {
const eslintrcFolderPath = path_1.default.dirname(require.resolve('@eslint/eslintrc/package.json', { paths: [currentModule.path] }));
// Make sure we actually resolved the module in our call path
// and not some other spurious dependency.
const resolvedEslintrcBundlePath = path_1.default.join(eslintrcFolderPath, 'dist/eslintrc.cjs');
if (resolvedEslintrcBundlePath === currentModule.filename) {
eslintrcBundlePath = resolvedEslintrcBundlePath;
}
}
catch (ex) {
// Module resolution failures are expected, as we're walking
// up our require stack to look for eslint. All other errors
// are re-thrown.
if (!isModuleResolutionError(ex)) {
throw ex;
}
}
}
}
else {
// Next look for a file in ESLint's folder
// .../eslint/lib/cli-engine/cli-engine.js
try {
const eslintCandidateFolder = path_1.default.dirname(require.resolve('eslint/package.json', {
paths: [currentModule.path]
}));
// Make sure we actually resolved the module in our call path
// and not some other spurious dependency.
if (currentModule.filename.startsWith(eslintCandidateFolder + path_1.default.sep)) {
exports.eslintFolder = eslintFolder = eslintCandidateFolder;
break;
}
}
catch (ex) {
// Module resolution failures are expected, as we're walking
// up our require stack to look for eslint. All other errors
// are re-thrown.
if (!isModuleResolutionError(ex)) {
throw ex;
}
}
}
if (!currentModule.parent) {
break;
}
currentModule = currentModule.parent;
}
}
if (!eslintFolder) {
// Probe for the ESLint >=7.12.0 layout:
for (let currentModule = module;;) {
if (!configArrayFactoryPath) {
// For ESLint >=7.12.0, config-array-factory.js is at this path:
// .../@eslint/eslintrc/lib/config-array-factory.js
try {
const eslintrcFolder = path_1.default.dirname(require.resolve('@eslint/eslintrc/package.json', {
paths: [currentModule.path]
}));
const resolvedConfigArrayFactoryPath = path_1.default.join(eslintrcFolder, '/lib/config-array-factory.js');
if (resolvedConfigArrayFactoryPath === currentModule.filename) {
configArrayFactoryPath = resolvedConfigArrayFactoryPath;
moduleResolverPath = `${eslintrcFolder}/lib/shared/relative-module-resolver`;
namingPath = `${eslintrcFolder}/lib/shared/naming`;
}
}
catch (ex) {
// Module resolution failures are expected, as we're walking
// up our require stack to look for eslint. All other errors
// are re-thrown.
if (!isModuleResolutionError(ex)) {
throw ex;
}
}
}
else if (currentModule.filename.endsWith('cli-engine.js')) {
// Next look for a file in ESLint's folder
// .../eslint/lib/cli-engine/cli-engine.js
try {
const eslintCandidateFolder = path_1.default.dirname(require.resolve('eslint/package.json', {
paths: [currentModule.path]
}));
if (path_1.default.join(eslintCandidateFolder, 'lib/cli-engine/cli-engine.js') === currentModule.filename) {
exports.eslintFolder = eslintFolder = eslintCandidateFolder;
break;
}
}
catch (ex) {
// Module resolution failures are expected, as we're walking
// up our require stack to look for eslint. All other errors
// are rethrown.
if (!isModuleResolutionError(ex)) {
throw ex;
}
}
}
if (!currentModule.parent) {
break;
}
currentModule = currentModule.parent;
}
}
if (!eslintFolder) {
// Probe for the <7.12.0 layout:
for (let currentModule = module;;) {
// For ESLint <7.12.0, config-array-factory.js was at this path:
// .../eslint/lib/cli-engine/config-array-factory.js
if (/[\\/]eslint[\\/]lib[\\/]cli-engine[\\/]config-array-factory\.js$/i.test(currentModule.filename)) {
exports.eslintFolder = eslintFolder = path_1.default.join(path_1.default.dirname(currentModule.filename), '../..');
configArrayFactoryPath = `${eslintFolder}/lib/cli-engine/config-array-factory`;
moduleResolverPath = `${eslintFolder}/lib/shared/relative-module-resolver`;
// The naming module was moved to @eslint/eslintrc in ESLint 7.8.0, which is also when the @eslint/eslintrc
// package was created and added to ESLint, so we need to probe for whether it's in the old or new location.
let eslintrcFolder;
try {
eslintrcFolder = path_1.default.dirname(require.resolve('@eslint/eslintrc/package.json', {
paths: [currentModule.path]
}));
}
catch (ex) {
if (!isModuleResolutionError(ex)) {
throw ex;
}
}
namingPath = `${eslintrcFolder !== null && eslintrcFolder !== void 0 ? eslintrcFolder : eslintFolder}/lib/shared/naming`;
break;
}
if (!currentModule.parent) {
// This was tested with ESLint 6.1.0 .. 7.12.1.
throw new Error('Failed to patch ESLint because the calling module was not recognized.\n' +
'If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:\n' +
'https://github.com/microsoft/rushstack/issues');
}
currentModule = currentModule.parent;
}
}
// Detect the ESLint package version
const eslintPackageJsonPath = `${eslintFolder}/package.json`;
const eslintPackageObject = require(eslintPackageJsonPath);
exports.eslintPackageVersion = eslintPackageObject.version;
const ESLINT_MAJOR_VERSION = parseInt(exports.eslintPackageVersion, 10);
exports.ESLINT_MAJOR_VERSION = ESLINT_MAJOR_VERSION;
if (isNaN(ESLINT_MAJOR_VERSION)) {
throw new Error(`Unable to parse ESLint version "${exports.eslintPackageVersion}" in file "${eslintPackageJsonPath}"`);
}
if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 9)) {
throw new Error('The ESLint patch script has only been tested with ESLint version 6.x, 7.x, 8.x, and 9.x.' +
` (Your version: ${exports.eslintPackageVersion})\n` +
'Consider reporting a GitHub issue:\n' +
'https://github.com/microsoft/rushstack/issues');
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let configArrayFactory;
if (ESLINT_MAJOR_VERSION >= 8 && eslintrcBundlePath) {
exports.configArrayFactory = configArrayFactory = require(eslintrcBundlePath).Legacy.ConfigArrayFactory;
}
else if (configArrayFactoryPath) {
exports.configArrayFactory = configArrayFactory = require(configArrayFactoryPath).ConfigArrayFactory;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let ModuleResolver;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let Naming;
if (ESLINT_MAJOR_VERSION >= 8 && eslintrcBundlePath) {
exports.ModuleResolver = ModuleResolver = require(eslintrcBundlePath).Legacy.ModuleResolver;
exports.Naming = Naming = require(eslintrcBundlePath).Legacy.naming;
}
else if (moduleResolverPath && namingPath) {
exports.ModuleResolver = ModuleResolver = require(moduleResolverPath);
exports.Naming = Naming = require(namingPath);
}
//# sourceMappingURL=_patch-base.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=custom-config-package-names.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"custom-config-package-names.d.ts","sourceRoot":"","sources":["../src/custom-config-package-names.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,47 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
// This is a workaround for ESLint's requirement to consume shareable configurations from package names prefixed
// with "eslint-config".
//
// To remove this requirement, add this line to the top of your project's .eslintrc.js file:
//
// require("@rushstack/eslint-patch/custom-config-package-names");
//
const _patch_base_1 = require("./_patch-base");
if (!_patch_base_1.configArrayFactory.__loadExtendedShareableConfigPatched) {
_patch_base_1.configArrayFactory.__loadExtendedShareableConfigPatched = true;
// eslint-disable-next-line @typescript-eslint/typedef
const originalLoadExtendedShareableConfig = _patch_base_1.configArrayFactory.prototype._loadExtendedShareableConfig;
// Common between ESLint versions
// https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L910
_patch_base_1.configArrayFactory.prototype._loadExtendedShareableConfig = function (extendName) {
const originalResolve = _patch_base_1.ModuleResolver.resolve;
try {
_patch_base_1.ModuleResolver.resolve = function (moduleName, relativeToPath) {
try {
return originalResolve.call(this, moduleName, relativeToPath);
}
catch (e) {
// Only change the name we resolve if we cannot find the normalized module, since it is
// valid to rely on the normalized package name. Use the originally provided module path
// instead of the normalized module path.
if ((e === null || e === void 0 ? void 0 : e.code) === 'MODULE_NOT_FOUND' &&
moduleName !== extendName &&
moduleName === _patch_base_1.Naming.normalizePackageName(extendName, 'eslint-config')) {
return originalResolve.call(this, extendName, relativeToPath);
}
else {
throw e;
}
}
};
return originalLoadExtendedShareableConfig.apply(this, arguments);
}
finally {
_patch_base_1.ModuleResolver.resolve = originalResolve;
}
};
}
//# sourceMappingURL=custom-config-package-names.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"custom-config-package-names.js","sourceRoot":"","sources":["../src/custom-config-package-names.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,gHAAgH;AAChH,wBAAwB;AACxB,EAAE;AACF,4FAA4F;AAC5F,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,+CAA2E;AAE3E,IAAI,CAAC,gCAAkB,CAAC,oCAAoC,EAAE,CAAC;IAC7D,gCAAkB,CAAC,oCAAoC,GAAG,IAAI,CAAC;IAC/D,sDAAsD;IACtD,MAAM,mCAAmC,GAAG,gCAAkB,CAAC,SAAS,CAAC,4BAA4B,CAAC;IAEtG,iCAAiC;IACjC,oHAAoH;IACpH,gCAAkB,CAAC,SAAS,CAAC,4BAA4B,GAAG,UAAU,UAAkB;QACtF,MAAM,eAAe,GAA2D,4BAAc,CAAC,OAAO,CAAC;QACvG,IAAI,CAAC;YACH,4BAAc,CAAC,OAAO,GAAG,UAAU,UAAkB,EAAE,cAAsB;gBAC3E,IAAI,CAAC;oBACH,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;gBAChE,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,uFAAuF;oBACvF,wFAAwF;oBACxF,yCAAyC;oBACzC,IACE,CAAC,CAA2B,aAA3B,CAAC,uBAAD,CAAC,CAA4B,IAAI,MAAK,kBAAkB;wBACzD,UAAU,KAAK,UAAU;wBACzB,UAAU,KAAK,oBAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,eAAe,CAAC,EACvE,CAAC;wBACD,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;oBAChE,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,CAAC;oBACV,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;YACF,OAAO,mCAAmC,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACpE,CAAC;gBAAS,CAAC;YACT,4BAAc,CAAC,OAAO,GAAG,eAAe,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n// This is a workaround for ESLint's requirement to consume shareable configurations from package names prefixed\n// with \"eslint-config\".\n//\n// To remove this requirement, add this line to the top of your project's .eslintrc.js file:\n//\n// require(\"@rushstack/eslint-patch/custom-config-package-names\");\n//\nimport { configArrayFactory, ModuleResolver, Naming } from './_patch-base';\n\nif (!configArrayFactory.__loadExtendedShareableConfigPatched) {\n configArrayFactory.__loadExtendedShareableConfigPatched = true;\n // eslint-disable-next-line @typescript-eslint/typedef\n const originalLoadExtendedShareableConfig = configArrayFactory.prototype._loadExtendedShareableConfig;\n\n // Common between ESLint versions\n // https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L910\n configArrayFactory.prototype._loadExtendedShareableConfig = function (extendName: string): unknown {\n const originalResolve: (moduleName: string, relativeToPath: string) => string = ModuleResolver.resolve;\n try {\n ModuleResolver.resolve = function (moduleName: string, relativeToPath: string): string {\n try {\n return originalResolve.call(this, moduleName, relativeToPath);\n } catch (e) {\n // Only change the name we resolve if we cannot find the normalized module, since it is\n // valid to rely on the normalized package name. Use the originally provided module path\n // instead of the normalized module path.\n if (\n (e as NodeJS.ErrnoException)?.code === 'MODULE_NOT_FOUND' &&\n moduleName !== extendName &&\n moduleName === Naming.normalizePackageName(extendName, 'eslint-config')\n ) {\n return originalResolve.call(this, extendName, relativeToPath);\n } else {\n throw e;\n }\n }\n };\n return originalLoadExtendedShareableConfig.apply(this, arguments);\n } finally {\n ModuleResolver.resolve = originalResolve;\n }\n };\n}\n"]}

View File

@@ -0,0 +1,81 @@
import type { TSESTree } from '@typescript-eslint/types';
export declare function isArrayExpression(node: TSESTree.Node): node is TSESTree.ArrayExpression;
export declare function isArrowFunctionExpression(node: TSESTree.Node): node is TSESTree.ArrowFunctionExpression;
/** default parameters */
export declare function isAssignmentPattern(node: TSESTree.Node): node is TSESTree.AssignmentPattern;
export declare function isClassDeclaration(node: TSESTree.Node): node is TSESTree.ClassDeclaration;
export declare function isClassExpression(node: TSESTree.Node): node is TSESTree.ClassExpression;
export declare function isExportDefaultDeclaration(node: TSESTree.Node): node is TSESTree.ExportDefaultDeclaration;
export declare function isExpression(node: TSESTree.Node): node is TSESTree.Expression;
export declare function isFunctionDeclaration(node: TSESTree.Node): node is TSESTree.FunctionDeclaration;
export declare function isFunctionExpression(node: TSESTree.Node): node is TSESTree.FunctionExpression;
export declare function isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier;
export declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
export declare function isMethodDefinition(node: TSESTree.Node): node is TSESTree.MethodDefinition;
export declare function isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression;
export declare function isPrivateIdentifier(node: TSESTree.Node): node is TSESTree.PrivateIdentifier;
export declare function isProperty(node: TSESTree.Node): node is TSESTree.Property;
export declare function isPropertyDefinition(node: TSESTree.Node): node is TSESTree.PropertyDefinition;
export declare function isTSEnumDeclaration(node: TSESTree.Node): node is TSESTree.TSEnumDeclaration;
export declare function isTSInterfaceDeclaration(node: TSESTree.Node): node is TSESTree.TSInterfaceDeclaration;
export declare function isTSModuleDeclaration(node: TSESTree.Node): node is TSESTree.TSModuleDeclaration;
export declare function isTSQualifiedName(node: TSESTree.Node): node is TSESTree.TSQualifiedName;
export declare function isTSTypeAliasDeclaration(node: TSESTree.Node): node is TSESTree.TSTypeAliasDeclaration;
export declare function isVariableDeclarator(node: TSESTree.Node): node is TSESTree.VariableDeclarator;
export declare function isClassDeclarationWithName(node: TSESTree.Node): node is TSESTree.ClassDeclarationWithName;
export declare function isClassPropertyNameNonComputed(node: TSESTree.Node): node is TSESTree.ClassPropertyNameNonComputed;
export declare function isFunctionDeclarationWithName(node: TSESTree.Node): node is TSESTree.FunctionDeclarationWithName;
export declare function isNumberLiteral(node: TSESTree.Node): node is TSESTree.NumberLiteral;
export declare function isPropertyNameNonComputed(node: TSESTree.Node): node is TSESTree.PropertyNameNonComputed;
export declare function isStringLiteral(node: TSESTree.Node): node is TSESTree.StringLiteral;
export interface IClassExpressionWithName extends TSESTree.ClassExpression {
id: TSESTree.Identifier;
}
export declare function isClassExpressionWithName(node: TSESTree.Node): node is IClassExpressionWithName;
export interface IFunctionExpressionWithName extends TSESTree.FunctionExpression {
id: TSESTree.Identifier;
}
export declare function isFunctionExpressionWithName(node: TSESTree.Node): node is IFunctionExpressionWithName;
export type NormalAnonymousExpression = TSESTree.ArrowFunctionExpression | TSESTree.ClassExpression | TSESTree.FunctionExpression | TSESTree.ObjectExpression;
export declare function isNormalAnonymousExpression(node: TSESTree.Node): node is NormalAnonymousExpression;
export interface INormalAssignmentPattern extends TSESTree.AssignmentPattern {
left: TSESTree.Identifier;
}
export declare function isNormalAssignmentPattern(node: TSESTree.Node): node is INormalAssignmentPattern;
export interface INormalClassPropertyDefinition extends TSESTree.PropertyDefinitionNonComputedName {
key: TSESTree.PrivateIdentifier | TSESTree.Identifier;
value: TSESTree.Expression;
}
export declare function isNormalClassPropertyDefinition(node: TSESTree.Node): node is INormalClassPropertyDefinition;
export interface INormalMethodDefinition extends TSESTree.MethodDefinitionNonComputedName {
key: TSESTree.PrivateIdentifier | TSESTree.Identifier;
}
export declare function isNormalMethodDefinition(node: TSESTree.Node): node is INormalMethodDefinition;
export interface INormalObjectProperty extends TSESTree.PropertyNonComputedName {
key: TSESTree.Identifier;
}
export declare function isNormalObjectProperty(node: TSESTree.Node): node is INormalObjectProperty;
export type INormalVariableDeclarator = TSESTree.LetOrConstOrVarDeclaration & {
id: TSESTree.Identifier;
init: TSESTree.Expression;
};
export declare function isNormalVariableDeclarator(node: TSESTree.Node): node is INormalVariableDeclarator;
export interface INormalAssignmentPatternWithAnonymousExpressionAssigned extends INormalAssignmentPattern {
right: NormalAnonymousExpression;
}
export declare function isNormalAssignmentPatternWithAnonymousExpressionAssigned(node: TSESTree.Node): node is INormalAssignmentPatternWithAnonymousExpressionAssigned;
export type INormalVariableDeclaratorWithAnonymousExpressionAssigned = INormalVariableDeclarator & {
init: NormalAnonymousExpression;
};
export declare function isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node: TSESTree.Node): node is INormalVariableDeclaratorWithAnonymousExpressionAssigned;
export interface INormalObjectPropertyWithAnonymousExpressionAssigned extends INormalObjectProperty {
value: NormalAnonymousExpression;
}
export declare function isNormalObjectPropertyWithAnonymousExpressionAssigned(node: TSESTree.Node): node is INormalObjectPropertyWithAnonymousExpressionAssigned;
export interface INormalClassPropertyDefinitionWithAnonymousExpressionAssigned extends INormalClassPropertyDefinition {
value: NormalAnonymousExpression;
}
export declare function isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node: TSESTree.Node): node is INormalClassPropertyDefinitionWithAnonymousExpressionAssigned;
export type NodeWithName = TSESTree.ClassDeclarationWithName | TSESTree.FunctionDeclarationWithName | IClassExpressionWithName | IFunctionExpressionWithName | INormalVariableDeclaratorWithAnonymousExpressionAssigned | INormalObjectPropertyWithAnonymousExpressionAssigned | INormalClassPropertyDefinitionWithAnonymousExpressionAssigned | INormalAssignmentPatternWithAnonymousExpressionAssigned | INormalMethodDefinition | TSESTree.TSEnumDeclaration | TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
export declare function isNodeWithName(node: TSESTree.Node): node is NodeWithName;
//# sourceMappingURL=ast-guards.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ast-guards.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/ast-guards.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,eAAe,CAEvF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,uBAAuB,CAEvG;AAED,yBAAyB;AACzB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,iBAAiB,CAE3F;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAEzF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,eAAe,CAEvF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,wBAAwB,CAEzG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,UAAU,CAE7E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,mBAAmB,CAE/F;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,kBAAkB,CAE7F;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,UAAU,CAE7E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,OAAO,CAEvE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAEzF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAEzF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,iBAAiB,CAE3F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,QAAQ,CAEzE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,kBAAkB,CAE7F;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,iBAAiB,CAE3F;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,sBAAsB,CAErG;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,mBAAmB,CAE/F;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,eAAe,CAEvF;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,sBAAsB,CAErG;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,kBAAkB,CAE7F;AAGD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,wBAAwB,CAEzG;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,QAAQ,CAAC,4BAA4B,CAE/C;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,QAAQ,CAAC,2BAA2B,CAE9C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,aAAa,CAEnF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,uBAAuB,CAEvG;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,aAAa,CAEnF;AAGD,MAAM,WAAW,wBAAyB,SAAQ,QAAQ,CAAC,eAAe;IACxE,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC;CACzB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,wBAAwB,CAE/F;AACD,MAAM,WAAW,2BAA4B,SAAQ,QAAQ,CAAC,kBAAkB;IAC9E,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC;CACzB;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,2BAA2B,CAErG;AAED,MAAM,MAAM,yBAAyB,GACjC,QAAQ,CAAC,uBAAuB,GAChC,QAAQ,CAAC,eAAe,GACxB,QAAQ,CAAC,kBAAkB,GAC3B,QAAQ,CAAC,gBAAgB,CAAC;AAE9B,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,yBAAyB,CAQlG;AAED,MAAM,WAAW,wBAAyB,SAAQ,QAAQ,CAAC,iBAAiB;IAC1E,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC3B;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,wBAAwB,CAE/F;AAED,MAAM,WAAW,8BAA+B,SAAQ,QAAQ,CAAC,iCAAiC;IAChG,GAAG,EAAE,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC;IACtD,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC5B;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,8BAA8B,CAM3G;AAED,MAAM,WAAW,uBAAwB,SAAQ,QAAQ,CAAC,+BAA+B;IACvF,GAAG,EAAE,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC;CACvD;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,uBAAuB,CAE7F;AAED,MAAM,WAAW,qBAAsB,SAAQ,QAAQ,CAAC,uBAAuB;IAC7E,GAAG,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC1B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,qBAAqB,CAEzF;AAED,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC,0BAA0B,GAAG;IAC5E,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC;IACxB,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC3B,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,yBAAyB,CAEjG;AAED,MAAM,WAAW,uDAAwD,SAAQ,wBAAwB;IACvG,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,wDAAwD,CACtE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,uDAAuD,CAEjE;AAED,MAAM,MAAM,wDAAwD,GAAG,yBAAyB,GAAG;IACjG,IAAI,EAAE,yBAAyB,CAAC;CACjC,CAAC;AAEF,wBAAgB,yDAAyD,CACvE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,wDAAwD,CAElE;AAED,MAAM,WAAW,oDAAqD,SAAQ,qBAAqB;IACjG,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,qDAAqD,CACnE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,oDAAoD,CAE9D;AAED,MAAM,WAAW,6DACf,SAAQ,8BAA8B;IACtC,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,8DAA8D,CAC5E,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,6DAA6D,CAEvE;AAED,MAAM,MAAM,YAAY,GACpB,QAAQ,CAAC,wBAAwB,GACjC,QAAQ,CAAC,2BAA2B,GACpC,wBAAwB,GACxB,2BAA2B,GAC3B,wDAAwD,GACxD,oDAAoD,GACpD,6DAA6D,GAC7D,uDAAuD,GACvD,uBAAuB,GACvB,QAAQ,CAAC,iBAAiB,GAC1B,QAAQ,CAAC,sBAAsB,GAC/B,QAAQ,CAAC,sBAAsB,CAAC;AAEpC,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,YAAY,CAexE"}

View File

@@ -0,0 +1,190 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArrayExpression = isArrayExpression;
exports.isArrowFunctionExpression = isArrowFunctionExpression;
exports.isAssignmentPattern = isAssignmentPattern;
exports.isClassDeclaration = isClassDeclaration;
exports.isClassExpression = isClassExpression;
exports.isExportDefaultDeclaration = isExportDefaultDeclaration;
exports.isExpression = isExpression;
exports.isFunctionDeclaration = isFunctionDeclaration;
exports.isFunctionExpression = isFunctionExpression;
exports.isIdentifier = isIdentifier;
exports.isLiteral = isLiteral;
exports.isMethodDefinition = isMethodDefinition;
exports.isObjectExpression = isObjectExpression;
exports.isPrivateIdentifier = isPrivateIdentifier;
exports.isProperty = isProperty;
exports.isPropertyDefinition = isPropertyDefinition;
exports.isTSEnumDeclaration = isTSEnumDeclaration;
exports.isTSInterfaceDeclaration = isTSInterfaceDeclaration;
exports.isTSModuleDeclaration = isTSModuleDeclaration;
exports.isTSQualifiedName = isTSQualifiedName;
exports.isTSTypeAliasDeclaration = isTSTypeAliasDeclaration;
exports.isVariableDeclarator = isVariableDeclarator;
exports.isClassDeclarationWithName = isClassDeclarationWithName;
exports.isClassPropertyNameNonComputed = isClassPropertyNameNonComputed;
exports.isFunctionDeclarationWithName = isFunctionDeclarationWithName;
exports.isNumberLiteral = isNumberLiteral;
exports.isPropertyNameNonComputed = isPropertyNameNonComputed;
exports.isStringLiteral = isStringLiteral;
exports.isClassExpressionWithName = isClassExpressionWithName;
exports.isFunctionExpressionWithName = isFunctionExpressionWithName;
exports.isNormalAnonymousExpression = isNormalAnonymousExpression;
exports.isNormalAssignmentPattern = isNormalAssignmentPattern;
exports.isNormalClassPropertyDefinition = isNormalClassPropertyDefinition;
exports.isNormalMethodDefinition = isNormalMethodDefinition;
exports.isNormalObjectProperty = isNormalObjectProperty;
exports.isNormalVariableDeclarator = isNormalVariableDeclarator;
exports.isNormalAssignmentPatternWithAnonymousExpressionAssigned = isNormalAssignmentPatternWithAnonymousExpressionAssigned;
exports.isNormalVariableDeclaratorWithAnonymousExpressionAssigned = isNormalVariableDeclaratorWithAnonymousExpressionAssigned;
exports.isNormalObjectPropertyWithAnonymousExpressionAssigned = isNormalObjectPropertyWithAnonymousExpressionAssigned;
exports.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned = isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned;
exports.isNodeWithName = isNodeWithName;
function isArrayExpression(node) {
return node.type === 'ArrayExpression';
}
function isArrowFunctionExpression(node) {
return node.type === 'ArrowFunctionExpression';
}
/** default parameters */
function isAssignmentPattern(node) {
return node.type === 'AssignmentPattern';
}
function isClassDeclaration(node) {
return node.type === 'ClassDeclaration';
}
function isClassExpression(node) {
return node.type === 'ClassExpression';
}
function isExportDefaultDeclaration(node) {
return node.type === 'ExportDefaultDeclaration';
}
function isExpression(node) {
return node.type.includes('Expression');
}
function isFunctionDeclaration(node) {
return node.type === 'FunctionDeclaration';
}
function isFunctionExpression(node) {
return node.type === 'FunctionExpression';
}
function isIdentifier(node) {
return node.type === 'Identifier';
}
function isLiteral(node) {
return node.type === 'Literal';
}
function isMethodDefinition(node) {
return node.type === 'MethodDefinition';
}
function isObjectExpression(node) {
return node.type === 'ObjectExpression';
}
function isPrivateIdentifier(node) {
return node.type === 'PrivateIdentifier';
}
function isProperty(node) {
return node.type === 'Property';
}
function isPropertyDefinition(node) {
return node.type === 'PropertyDefinition';
}
function isTSEnumDeclaration(node) {
return node.type === 'TSEnumDeclaration';
}
function isTSInterfaceDeclaration(node) {
return node.type === 'TSInterfaceDeclaration';
}
function isTSModuleDeclaration(node) {
return node.type === 'TSModuleDeclaration';
}
function isTSQualifiedName(node) {
return node.type === 'TSQualifiedName';
}
function isTSTypeAliasDeclaration(node) {
return node.type === 'TSTypeAliasDeclaration';
}
function isVariableDeclarator(node) {
return node.type === 'VariableDeclarator';
}
// Compound Type Guards for @typescript-eslint/types ast-spec compound types
function isClassDeclarationWithName(node) {
return isClassDeclaration(node) && node.id !== null;
}
function isClassPropertyNameNonComputed(node) {
return isPrivateIdentifier(node) || isPropertyNameNonComputed(node);
}
function isFunctionDeclarationWithName(node) {
return isFunctionDeclaration(node) && node.id !== null;
}
function isNumberLiteral(node) {
return isLiteral(node) && typeof node.value === 'number';
}
function isPropertyNameNonComputed(node) {
return isIdentifier(node) || isNumberLiteral(node) || isStringLiteral(node);
}
function isStringLiteral(node) {
return isLiteral(node) && typeof node.value === 'string';
}
function isClassExpressionWithName(node) {
return isClassExpression(node) && node.id !== null;
}
function isFunctionExpressionWithName(node) {
return isFunctionExpression(node) && node.id !== null;
}
function isNormalAnonymousExpression(node) {
const ANONYMOUS_EXPRESSION_GUARDS = [
isArrowFunctionExpression,
isClassExpression,
isFunctionExpression,
isObjectExpression
];
return ANONYMOUS_EXPRESSION_GUARDS.some((guard) => guard(node));
}
function isNormalAssignmentPattern(node) {
return isAssignmentPattern(node) && isIdentifier(node.left);
}
function isNormalClassPropertyDefinition(node) {
return (isPropertyDefinition(node) &&
(isIdentifier(node.key) || isPrivateIdentifier(node.key)) &&
node.value !== null);
}
function isNormalMethodDefinition(node) {
return isMethodDefinition(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
function isNormalObjectProperty(node) {
return isProperty(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
function isNormalVariableDeclarator(node) {
return isVariableDeclarator(node) && isIdentifier(node.id) && node.init !== null;
}
function isNormalAssignmentPatternWithAnonymousExpressionAssigned(node) {
return isNormalAssignmentPattern(node) && isNormalAnonymousExpression(node.right);
}
function isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node) {
return isNormalVariableDeclarator(node) && isNormalAnonymousExpression(node.init);
}
function isNormalObjectPropertyWithAnonymousExpressionAssigned(node) {
return isNormalObjectProperty(node) && isNormalAnonymousExpression(node.value);
}
function isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node) {
return isNormalClassPropertyDefinition(node) && isNormalAnonymousExpression(node.value);
}
function isNodeWithName(node) {
return (isClassDeclarationWithName(node) ||
isFunctionDeclarationWithName(node) ||
isClassExpressionWithName(node) ||
isFunctionExpressionWithName(node) ||
isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node) ||
isNormalObjectPropertyWithAnonymousExpressionAssigned(node) ||
isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node) ||
isNormalAssignmentPatternWithAnonymousExpressionAssigned(node) ||
isNormalMethodDefinition(node) ||
isTSEnumDeclaration(node) ||
isTSInterfaceDeclaration(node) ||
isTSTypeAliasDeclaration(node));
}
//# sourceMappingURL=ast-guards.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
export interface ISuppression {
file: string;
scopeId: string;
rule: string;
}
export interface IBulkSuppressionsConfig {
serializedSuppressions: Set<string>;
jsonObject: IBulkSuppressionsJson;
newSerializedSuppressions: Set<string>;
newJsonObject: IBulkSuppressionsJson;
}
export interface IBulkSuppressionsJson {
suppressions: ISuppression[];
}
export declare function getSuppressionsConfigForEslintConfigFolderPath(eslintConfigFolderPath: string): IBulkSuppressionsConfig;
export declare function getAllBulkSuppressionsConfigsByEslintConfigFolderPath(): [string, IBulkSuppressionsConfig][];
export declare function writeSuppressionsJsonToFile(eslintConfigFolderPath: string, suppressionsConfig: IBulkSuppressionsConfig): void;
export declare function deleteBulkSuppressionsFileInEslintConfigFolder(eslintConfigFolderPath: string): void;
export declare function serializeSuppression({ file, scopeId, rule }: ISuppression): string;
//# sourceMappingURL=bulk-suppressions-file.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bulk-suppressions-file.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/bulk-suppressions-file.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,qBAAqB,CAAC;IAClC,yBAAyB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,aAAa,EAAE,qBAAqB,CAAC;CACtC;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,YAAY,EAAE,CAAC;CAC9B;AAkBD,wBAAgB,8CAA8C,CAC5D,sBAAsB,EAAE,MAAM,GAC7B,uBAAuB,CAkDzB;AAED,wBAAgB,qDAAqD,IAAI,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAAE,CAO3G;AAED,wBAAgB,2BAA2B,CACzC,sBAAsB,EAAE,MAAM,EAC9B,kBAAkB,EAAE,uBAAuB,GAC1C,IAAI,CASN;AAED,wBAAgB,8CAA8C,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAGnG;AAUD,wBAAgB,oBAAoB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,YAAY,GAAG,MAAM,CAElF"}

View File

@@ -0,0 +1,171 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSuppressionsConfigForEslintConfigFolderPath = getSuppressionsConfigForEslintConfigFolderPath;
exports.getAllBulkSuppressionsConfigsByEslintConfigFolderPath = getAllBulkSuppressionsConfigsByEslintConfigFolderPath;
exports.writeSuppressionsJsonToFile = writeSuppressionsJsonToFile;
exports.deleteBulkSuppressionsFileInEslintConfigFolder = deleteBulkSuppressionsFileInEslintConfigFolder;
exports.serializeSuppression = serializeSuppression;
const fs_1 = __importDefault(require("fs"));
const constants_1 = require("./constants");
const IS_RUNNING_IN_VSCODE = process.env[constants_1.VSCODE_PID_ENV_VAR_NAME] !== undefined;
const TEN_SECONDS_MS = 10 * 1000;
const SUPPRESSIONS_JSON_FILENAME = '.eslint-bulk-suppressions.json';
function throwIfAnythingOtherThanNotExistError(e) {
if ((e === null || e === void 0 ? void 0 : e.code) !== 'ENOENT') {
// Throw an error if any other error than file not found
throw e;
}
}
const suppressionsJsonByFolderPath = new Map();
function getSuppressionsConfigForEslintConfigFolderPath(eslintConfigFolderPath) {
const cachedSuppressionsConfig = suppressionsJsonByFolderPath.get(eslintConfigFolderPath);
let shouldLoad;
let suppressionsConfig;
if (cachedSuppressionsConfig) {
shouldLoad = IS_RUNNING_IN_VSCODE && cachedSuppressionsConfig.readTime < Date.now() - TEN_SECONDS_MS;
suppressionsConfig = cachedSuppressionsConfig.suppressionsConfig;
}
else {
shouldLoad = true;
}
if (shouldLoad) {
const suppressionsPath = `${eslintConfigFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`;
let rawJsonFile;
try {
rawJsonFile = fs_1.default.readFileSync(suppressionsPath).toString();
}
catch (e) {
throwIfAnythingOtherThanNotExistError(e);
}
if (!rawJsonFile) {
suppressionsConfig = {
serializedSuppressions: new Set(),
jsonObject: { suppressions: [] },
newSerializedSuppressions: new Set(),
newJsonObject: { suppressions: [] }
};
}
else {
const jsonObject = JSON.parse(rawJsonFile);
validateSuppressionsJson(jsonObject);
const serializedSuppressions = new Set();
for (const suppression of jsonObject.suppressions) {
serializedSuppressions.add(serializeSuppression(suppression));
}
suppressionsConfig = {
serializedSuppressions,
jsonObject,
newSerializedSuppressions: new Set(),
newJsonObject: { suppressions: [] }
};
}
suppressionsJsonByFolderPath.set(eslintConfigFolderPath, { readTime: Date.now(), suppressionsConfig });
}
return suppressionsConfig;
}
function getAllBulkSuppressionsConfigsByEslintConfigFolderPath() {
const result = [];
for (const [eslintConfigFolderPath, { suppressionsConfig }] of suppressionsJsonByFolderPath) {
result.push([eslintConfigFolderPath, suppressionsConfig]);
}
return result;
}
function writeSuppressionsJsonToFile(eslintConfigFolderPath, suppressionsConfig) {
suppressionsJsonByFolderPath.set(eslintConfigFolderPath, { readTime: Date.now(), suppressionsConfig });
const suppressionsPath = `${eslintConfigFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`;
if (suppressionsConfig.jsonObject.suppressions.length === 0) {
deleteFile(suppressionsPath);
}
else {
suppressionsConfig.jsonObject.suppressions.sort(compareSuppressions);
fs_1.default.writeFileSync(suppressionsPath, JSON.stringify(suppressionsConfig.jsonObject, undefined, 2));
}
}
function deleteBulkSuppressionsFileInEslintConfigFolder(eslintConfigFolderPath) {
const suppressionsPath = `${eslintConfigFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`;
deleteFile(suppressionsPath);
}
function deleteFile(filePath) {
try {
fs_1.default.unlinkSync(filePath);
}
catch (e) {
throwIfAnythingOtherThanNotExistError(e);
}
}
function serializeSuppression({ file, scopeId, rule }) {
return `${file}|${scopeId}|${rule}`;
}
function compareSuppressions(a, b) {
if (a.file < b.file) {
return -1;
}
else if (a.file > b.file) {
return 1;
}
else if (a.scopeId < b.scopeId) {
return -1;
}
else if (a.scopeId > b.scopeId) {
return 1;
}
else if (a.rule < b.rule) {
return -1;
}
else if (a.rule > b.rule) {
return 1;
}
else {
return 0;
}
}
function validateSuppressionsJson(json) {
if (typeof json !== 'object') {
throw new Error(`Invalid JSON object: ${JSON.stringify(json, null, 2)}`);
}
if (!json) {
throw new Error('JSON object is null.');
}
const EXPECTED_ROOT_PROPERTY_NAMES = new Set(['suppressions']);
for (const propertyName of Object.getOwnPropertyNames(json)) {
if (!EXPECTED_ROOT_PROPERTY_NAMES.has(propertyName)) {
throw new Error(`Unexpected property name: ${propertyName}`);
}
}
const { suppressions } = json;
if (!suppressions) {
throw new Error('Missing "suppressions" property.');
}
if (!Array.isArray(suppressions)) {
throw new Error('"suppressions" property is not an array.');
}
const EXPECTED_SUPPRESSION_PROPERTY_NAMES = new Set(['file', 'scopeId', 'rule']);
for (const suppression of suppressions) {
if (typeof suppression !== 'object') {
throw new Error(`Invalid suppression: ${JSON.stringify(suppression, null, 2)}`);
}
if (!suppression) {
throw new Error(`Suppression is null: ${JSON.stringify(suppression, null, 2)}`);
}
for (const propertyName of Object.getOwnPropertyNames(suppression)) {
if (!EXPECTED_SUPPRESSION_PROPERTY_NAMES.has(propertyName)) {
throw new Error(`Unexpected property name: ${propertyName}`);
}
}
for (const propertyName of EXPECTED_SUPPRESSION_PROPERTY_NAMES) {
if (!suppression.hasOwnProperty(propertyName)) {
throw new Error(`Missing "${propertyName}" property in suppression: ${JSON.stringify(suppression, null, 2)}`);
}
else if (typeof suppression[propertyName] !== 'string') {
throw new Error(`"${propertyName}" property in suppression is not a string: ${JSON.stringify(suppression, null, 2)}`);
}
}
}
return true;
}
//# sourceMappingURL=bulk-suppressions-file.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,29 @@
import type { TSESTree } from '@typescript-eslint/types';
import { type IBulkSuppressionsConfig, type ISuppression } from './bulk-suppressions-file';
declare const SUPPRESSION_SYMBOL: unique symbol;
interface IProblem {
[SUPPRESSION_SYMBOL]?: {
config: IBulkSuppressionsConfig;
suppression: ISuppression;
serializedSuppression: string;
};
}
export declare function shouldBulkSuppress(params: {
filename: string;
currentNode: TSESTree.Node;
ruleId: string;
problem: IProblem;
}): boolean;
export declare function prune(): void;
export declare function write(): void;
export declare function requireFromPathToLinterJS(importPath: string): import('eslint-9').Linter | import('eslint-8').Linter;
export declare function patchClass<T, U extends T>(originalClass: new () => T, patchedClass: new () => U): void;
/**
* This returns a wrapped version of the "verify" function from ESLint's Linter class
* that postprocesses rule violations that weren't suppressed by comments. This postprocessing
* records suppressions that weren't otherwise suppressed by comments to be used
* by the "suppress" and "prune" commands.
*/
export declare function extendVerifyFunction(originalFn: (this: unknown, ...args: unknown[]) => IProblem[] | undefined): (this: unknown, ...args: unknown[]) => IProblem[] | undefined;
export {};
//# sourceMappingURL=bulk-suppressions-patch.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bulk-suppressions-patch.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/bulk-suppressions-patch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAWzD,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EAGlB,MAAM,0BAA0B,CAAC;AAWlC,QAAA,MAAM,kBAAkB,EAAE,OAAO,MAA8B,CAAC;AAOhE,UAAU,QAAQ;IAChB,CAAC,kBAAkB,CAAC,CAAC,EAAE;QACrB,MAAM,EAAE,uBAAuB,CAAC;QAChC,WAAW,EAAE,YAAY,CAAC;QAC1B,qBAAqB,EAAE,MAAM,CAAC;KAC/B,CAAC;CACH;AAiGD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC;CACnB,GAAG,OAAO,CA4BV;AAED,wBAAgB,KAAK,IAAI,IAAI,CAiB5B;AAED,wBAAgB,KAAK,IAAI,IAAI,CAS5B;AAGD,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,GACjB,OAAO,UAAU,EAAE,MAAM,GAAG,OAAO,UAAU,EAAE,MAAM,CAQvD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,UAAU,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,GAAG,IAAI,CAgBtG;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,GAAG,SAAS,GACxE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,GAAG,SAAS,CA0B/D"}

View File

@@ -0,0 +1,248 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
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 () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldBulkSuppress = shouldBulkSuppress;
exports.prune = prune;
exports.write = write;
exports.requireFromPathToLinterJS = requireFromPathToLinterJS;
exports.patchClass = patchClass;
exports.extendVerifyFunction = extendVerifyFunction;
const fs_1 = __importDefault(require("fs"));
const Guards = __importStar(require("./ast-guards"));
const _patch_base_1 = require("../_patch-base");
const constants_1 = require("./constants");
const bulk_suppressions_file_1 = require("./bulk-suppressions-file");
const ESLINT_CONFIG_FILENAMES = [
'eslint.config.js',
'eslint.config.cjs',
'eslint.config.mjs',
'.eslintrc.js',
'.eslintrc.cjs'
// Several other filenames are allowed, but this patch requires that it be loaded via a JS config file,
// so we only need to check for the JS-based filenames
];
const SUPPRESSION_SYMBOL = Symbol('suppression');
const ESLINT_BULK_SUPPRESS_ENV_VAR_VALUE = process.env[constants_1.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME];
const SUPPRESS_ALL_RULES = ESLINT_BULK_SUPPRESS_ENV_VAR_VALUE === '*';
const RULES_TO_SUPPRESS = ESLINT_BULK_SUPPRESS_ENV_VAR_VALUE
? new Set(ESLINT_BULK_SUPPRESS_ENV_VAR_VALUE.split(','))
: undefined;
function getNodeName(node) {
if (Guards.isClassDeclarationWithName(node)) {
return node.id.name;
}
else if (Guards.isFunctionDeclarationWithName(node)) {
return node.id.name;
}
else if (Guards.isClassExpressionWithName(node)) {
return node.id.name;
}
else if (Guards.isFunctionExpressionWithName(node)) {
return node.id.name;
}
else if (Guards.isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node)) {
return node.id.name;
}
else if (Guards.isNormalObjectPropertyWithAnonymousExpressionAssigned(node)) {
return node.key.name;
}
else if (Guards.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node)) {
return node.key.name;
}
else if (Guards.isNormalAssignmentPatternWithAnonymousExpressionAssigned(node)) {
return node.left.name;
}
else if (Guards.isNormalMethodDefinition(node)) {
return node.key.name;
}
else if (Guards.isTSEnumDeclaration(node)) {
return node.id.name;
}
else if (Guards.isTSInterfaceDeclaration(node)) {
return node.id.name;
}
else if (Guards.isTSTypeAliasDeclaration(node)) {
return node.id.name;
}
}
function calculateScopeId(node) {
const scopeIds = [];
for (let current = node; current; current = current.parent) {
const scopeIdForASTNode = getNodeName(current);
if (scopeIdForASTNode !== undefined) {
scopeIds.unshift(scopeIdForASTNode);
}
}
if (scopeIds.length === 0) {
return '.';
}
else {
return '.' + scopeIds.join('.');
}
}
const eslintConfigPathByFileOrFolderPath = new Map();
function findEslintConfigFolderPathForNormalizedFileAbsolutePath(normalizedFilePath) {
const cachedFolderPathForFilePath = eslintConfigPathByFileOrFolderPath.get(normalizedFilePath);
if (cachedFolderPathForFilePath) {
return cachedFolderPathForFilePath;
}
const normalizedFileFolderPath = normalizedFilePath.substring(0, normalizedFilePath.lastIndexOf('/'));
const pathsToCache = [normalizedFilePath];
let eslintConfigFolderPath;
findEslintConfigFileLoop: for (let currentFolder = normalizedFileFolderPath; currentFolder; // 'something'.substring(0, -1) is ''
currentFolder = currentFolder.substring(0, currentFolder.lastIndexOf('/'))) {
const cachedEslintrcFolderPath = eslintConfigPathByFileOrFolderPath.get(currentFolder);
if (cachedEslintrcFolderPath) {
// Need to cache this result into the intermediate paths
eslintConfigFolderPath = cachedEslintrcFolderPath;
break;
}
pathsToCache.push(currentFolder);
for (const eslintConfigFilename of ESLINT_CONFIG_FILENAMES) {
if (fs_1.default.existsSync(`${currentFolder}/${eslintConfigFilename}`)) {
eslintConfigFolderPath = currentFolder;
break findEslintConfigFileLoop;
}
}
}
if (eslintConfigFolderPath) {
for (const checkedFolder of pathsToCache) {
eslintConfigPathByFileOrFolderPath.set(checkedFolder, eslintConfigFolderPath);
}
return eslintConfigFolderPath;
}
else {
throw new Error(`Cannot locate an ESLint configuration file for ${normalizedFilePath}`);
}
}
// One-line insert into the ruleContext report method to prematurely exit if the ESLint problem has been suppressed
function shouldBulkSuppress(params) {
// Use this ENV variable to turn off eslint-bulk-suppressions functionality, default behavior is on
if (process.env[constants_1.ESLINT_BULK_ENABLE_ENV_VAR_NAME] === 'false') {
return false;
}
const { filename: fileAbsolutePath, currentNode, ruleId: rule, problem } = params;
const normalizedFileAbsolutePath = fileAbsolutePath.replace(/\\/g, '/');
const eslintConfigDirectory = findEslintConfigFolderPathForNormalizedFileAbsolutePath(normalizedFileAbsolutePath);
const fileRelativePath = normalizedFileAbsolutePath.substring(eslintConfigDirectory.length + 1);
const scopeId = calculateScopeId(currentNode);
const suppression = { file: fileRelativePath, scopeId, rule };
const config = (0, bulk_suppressions_file_1.getSuppressionsConfigForEslintConfigFolderPath)(eslintConfigDirectory);
const serializedSuppression = (0, bulk_suppressions_file_1.serializeSuppression)(suppression);
const currentNodeIsSuppressed = config.serializedSuppressions.has(serializedSuppression);
if (currentNodeIsSuppressed || SUPPRESS_ALL_RULES || (RULES_TO_SUPPRESS === null || RULES_TO_SUPPRESS === void 0 ? void 0 : RULES_TO_SUPPRESS.has(suppression.rule))) {
problem[SUPPRESSION_SYMBOL] = {
suppression,
serializedSuppression,
config
};
}
return process.env[constants_1.ESLINT_BULK_PRUNE_ENV_VAR_NAME] !== '1' && currentNodeIsSuppressed;
}
function prune() {
for (const [eslintConfigFolderPath, suppressionsConfig] of (0, bulk_suppressions_file_1.getAllBulkSuppressionsConfigsByEslintConfigFolderPath)()) {
if (suppressionsConfig) {
const { newSerializedSuppressions, newJsonObject } = suppressionsConfig;
const newSuppressionsConfig = {
serializedSuppressions: newSerializedSuppressions,
jsonObject: newJsonObject,
newSerializedSuppressions: new Set(),
newJsonObject: { suppressions: [] }
};
(0, bulk_suppressions_file_1.writeSuppressionsJsonToFile)(eslintConfigFolderPath, newSuppressionsConfig);
}
}
}
function write() {
for (const [eslintrcFolderPath, suppressionsConfig] of (0, bulk_suppressions_file_1.getAllBulkSuppressionsConfigsByEslintConfigFolderPath)()) {
if (suppressionsConfig) {
(0, bulk_suppressions_file_1.writeSuppressionsJsonToFile)(eslintrcFolderPath, suppressionsConfig);
}
}
}
// utility function for linter-patch.js to make require statements that use relative paths in linter.js work in linter-patch.js
function requireFromPathToLinterJS(importPath) {
if (!_patch_base_1.eslintFolder) {
return require(importPath);
}
const pathToLinterFolder = `${_patch_base_1.eslintFolder}/lib/linter`;
const moduleAbsolutePath = require.resolve(importPath, { paths: [pathToLinterFolder] });
return require(moduleAbsolutePath);
}
function patchClass(originalClass, patchedClass) {
// Get all the property names of the patched class prototype
const patchedProperties = Object.getOwnPropertyNames(patchedClass.prototype);
// Loop through all the properties
for (const prop of patchedProperties) {
// Override the property in the original class
originalClass.prototype[prop] = patchedClass.prototype[prop];
}
// Handle getters and setters
for (const [prop, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(patchedClass.prototype))) {
if (descriptor.get || descriptor.set) {
Object.defineProperty(originalClass.prototype, prop, descriptor);
}
}
}
/**
* This returns a wrapped version of the "verify" function from ESLint's Linter class
* that postprocesses rule violations that weren't suppressed by comments. This postprocessing
* records suppressions that weren't otherwise suppressed by comments to be used
* by the "suppress" and "prune" commands.
*/
function extendVerifyFunction(originalFn) {
return function (...args) {
const problems = originalFn.apply(this, args);
if (problems) {
for (const problem of problems) {
if (problem[SUPPRESSION_SYMBOL]) {
const { serializedSuppression, suppression, config: { newSerializedSuppressions, jsonObject: { suppressions }, newJsonObject: { suppressions: newSuppressions } } } = problem[SUPPRESSION_SYMBOL];
if (!newSerializedSuppressions.has(serializedSuppression)) {
newSerializedSuppressions.add(serializedSuppression);
newSuppressions.push(suppression);
suppressions.push(suppression);
}
}
}
}
return problems;
};
}
//# sourceMappingURL=bulk-suppressions-patch.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare function pruneAsync(): Promise<void>;
//# sourceMappingURL=prune.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/prune.ts"],"names":[],"mappings":"AAaA,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBhD"}

View File

@@ -0,0 +1,60 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pruneAsync = pruneAsync;
const fs_1 = __importDefault(require("fs"));
const print_help_1 = require("./utils/print-help");
const runEslint_1 = require("./runEslint");
const constants_1 = require("../constants");
const bulk_suppressions_file_1 = require("../bulk-suppressions-file");
async function pruneAsync() {
const args = process.argv.slice(3);
if (args.includes('--help') || args.includes('-h')) {
(0, print_help_1.printPruneHelp)();
process.exit(0);
}
if (args.length > 0) {
throw new Error(`@rushstack/eslint-bulk: Unknown arguments: ${args.join(' ')}`);
}
const normalizedCwd = process.cwd().replace(/\\/g, '/');
const allFiles = await getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd);
if (allFiles.length > 0) {
process.env[constants_1.ESLINT_BULK_PRUNE_ENV_VAR_NAME] = '1';
console.log(`Pruning suppressions for ${allFiles.length} files...`);
await (0, runEslint_1.runEslintAsync)(allFiles, 'prune');
}
else {
console.log('No files with existing suppressions found.');
(0, bulk_suppressions_file_1.deleteBulkSuppressionsFileInEslintConfigFolder)(normalizedCwd);
}
}
async function getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd) {
const { jsonObject: bulkSuppressionsConfigJson } = (0, bulk_suppressions_file_1.getSuppressionsConfigForEslintConfigFolderPath)(normalizedCwd);
const allFiles = new Set();
for (const { file: filePath } of bulkSuppressionsConfigJson.suppressions) {
allFiles.add(filePath);
}
const allFilesArray = Array.from(allFiles);
const allExistingFiles = [];
// TODO: limit parallelism here with something similar to `Async.forEachAsync` from `node-core-library`.
await Promise.all(allFilesArray.map(async (filePath) => {
try {
await fs_1.default.promises.access(filePath, fs_1.default.constants.F_OK);
allExistingFiles.push(filePath);
}
catch (_a) {
// Doesn't exist - ignore
}
}));
console.log(`Found ${allExistingFiles.length} files with existing suppressions.`);
const deletedCount = allFilesArray.length - allExistingFiles.length;
if (deletedCount > 0) {
console.log(`${deletedCount} files with suppressions were deleted.`);
}
return allExistingFiles;
}
//# sourceMappingURL=prune.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/prune.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;AAY3D,gCAsBC;AAhCD,4CAAoB;AAEpB,mDAAoD;AACpD,2CAA6C;AAC7C,4CAA8D;AAC9D,sEAGmC;AAE5B,KAAK,UAAU,UAAU;IAC9B,MAAM,IAAI,GAAa,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE7C,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,IAAA,2BAAc,GAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8CAA8C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,aAAa,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAa,MAAM,8CAA8C,CAAC,aAAa,CAAC,CAAC;IAC/F,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,0CAA8B,CAAC,GAAG,GAAG,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,4BAA4B,QAAQ,CAAC,MAAM,WAAW,CAAC,CAAC;QACpE,MAAM,IAAA,0BAAc,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAC1D,IAAA,uEAA8C,EAAC,aAAa,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,8CAA8C,CAAC,aAAqB;IACjF,MAAM,EAAE,UAAU,EAAE,0BAA0B,EAAE,GAC9C,IAAA,uEAA8C,EAAC,aAAa,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAgB,IAAI,GAAG,EAAE,CAAC;IACxC,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,0BAA0B,CAAC,YAAY,EAAE,CAAC;QACzE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,aAAa,GAAa,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAErD,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,wGAAwG;IACxG,MAAM,OAAO,CAAC,GAAG,CACf,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,QAAgB,EAAE,EAAE;QAC3C,IAAI,CAAC;YACH,MAAM,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACtD,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;QAAC,WAAM,CAAC;YACP,yBAAyB;QAC3B,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,SAAS,gBAAgB,CAAC,MAAM,oCAAoC,CAAC,CAAC;IAClF,MAAM,YAAY,GAAW,aAAa,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC5E,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,GAAG,YAAY,wCAAwC,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport fs from 'fs';\n\nimport { printPruneHelp } from './utils/print-help';\nimport { runEslintAsync } from './runEslint';\nimport { ESLINT_BULK_PRUNE_ENV_VAR_NAME } from '../constants';\nimport {\n deleteBulkSuppressionsFileInEslintConfigFolder,\n getSuppressionsConfigForEslintConfigFolderPath\n} from '../bulk-suppressions-file';\n\nexport async function pruneAsync(): Promise<void> {\n const args: string[] = process.argv.slice(3);\n\n if (args.includes('--help') || args.includes('-h')) {\n printPruneHelp();\n process.exit(0);\n }\n\n if (args.length > 0) {\n throw new Error(`@rushstack/eslint-bulk: Unknown arguments: ${args.join(' ')}`);\n }\n\n const normalizedCwd: string = process.cwd().replace(/\\\\/g, '/');\n const allFiles: string[] = await getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd);\n if (allFiles.length > 0) {\n process.env[ESLINT_BULK_PRUNE_ENV_VAR_NAME] = '1';\n console.log(`Pruning suppressions for ${allFiles.length} files...`);\n await runEslintAsync(allFiles, 'prune');\n } else {\n console.log('No files with existing suppressions found.');\n deleteBulkSuppressionsFileInEslintConfigFolder(normalizedCwd);\n }\n}\n\nasync function getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd: string): Promise<string[]> {\n const { jsonObject: bulkSuppressionsConfigJson } =\n getSuppressionsConfigForEslintConfigFolderPath(normalizedCwd);\n const allFiles: Set<string> = new Set();\n for (const { file: filePath } of bulkSuppressionsConfigJson.suppressions) {\n allFiles.add(filePath);\n }\n\n const allFilesArray: string[] = Array.from(allFiles);\n\n const allExistingFiles: string[] = [];\n // TODO: limit parallelism here with something similar to `Async.forEachAsync` from `node-core-library`.\n await Promise.all(\n allFilesArray.map(async (filePath: string) => {\n try {\n await fs.promises.access(filePath, fs.constants.F_OK);\n allExistingFiles.push(filePath);\n } catch {\n // Doesn't exist - ignore\n }\n })\n );\n\n console.log(`Found ${allExistingFiles.length} files with existing suppressions.`);\n const deletedCount: number = allFilesArray.length - allExistingFiles.length;\n if (deletedCount > 0) {\n console.log(`${deletedCount} files with suppressions were deleted.`);\n }\n\n return allExistingFiles;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare function runEslintAsync(files: string[], mode: 'suppress' | 'prune'): Promise<void>;
//# sourceMappingURL=runEslint.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runEslint.d.ts","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/runEslint.ts"],"names":[],"mappings":"AAOA,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA4C/F"}

View File

@@ -0,0 +1,79 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
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 () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.runEslintAsync = runEslintAsync;
const get_eslint_cli_1 = require("./utils/get-eslint-cli");
async function runEslintAsync(files, mode) {
const cwd = process.cwd();
const [eslintPath, eslintVersion] = (0, get_eslint_cli_1.getEslintPathAndVersion)(cwd);
const { ESLint } = require(eslintPath);
let eslint;
const majorVersion = parseInt(eslintVersion, 10);
if (majorVersion < 9) {
eslint = new ESLint({ cwd, useEslintrc: true });
}
else {
eslint = new ESLint({ cwd });
}
let results;
try {
results = await eslint.lintFiles(files);
}
catch (e) {
throw new Error(`@rushstack/eslint-bulk execution error: ${e.message}`);
}
const { write, prune } = await Promise.resolve().then(() => __importStar(require('../bulk-suppressions-patch')));
switch (mode) {
case 'suppress': {
await write();
break;
}
case 'prune': {
await prune();
break;
}
}
if (results.length > 0) {
const stylishFormatter = await eslint.loadFormatter();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const formattedResults = await Promise.resolve(stylishFormatter.format(results));
console.log(formattedResults);
}
console.log('@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json ' +
`files under directory ${cwd}`);
}
//# sourceMappingURL=runEslint.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runEslint.js","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/runEslint.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM3D,wCA4CC;AA9CD,2DAAiE;AAE1D,KAAK,UAAU,cAAc,CAAC,KAAe,EAAE,IAA0B;IAC9E,MAAM,GAAG,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,wCAAuB,EAAC,GAAG,CAAC,CAAC;IACjE,MAAM,EAAE,MAAM,EAAE,GAA0D,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9F,IAAI,MAA+B,CAAC;IACpC,MAAM,YAAY,GAAW,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IACzD,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,OAA0D,CAAC;IAC/D,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,wDAAa,4BAA4B,GAAC,CAAC;IACpE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,MAAM,KAAK,EAAE,CAAC;YACd,MAAM;QACR,CAAC;QAED,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,KAAK,EAAE,CAAC;YACd,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,gBAAgB,GAAgD,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;QACnG,8DAA8D;QAC9D,MAAM,gBAAgB,GAAW,MAAM,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAc,CAAC,CAAC,CAAC;QAChG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,GAAG,CACT,wGAAwG;QACtG,yBAAyB,GAAG,EAAE,CACjC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ESLint as TEslintLegacy } from 'eslint-8';\nimport type { ESLint as TEslint } from 'eslint-9';\nimport { getEslintPathAndVersion } from './utils/get-eslint-cli';\n\nexport async function runEslintAsync(files: string[], mode: 'suppress' | 'prune'): Promise<void> {\n const cwd: string = process.cwd();\n const [eslintPath, eslintVersion] = getEslintPathAndVersion(cwd);\n const { ESLint }: typeof import('eslint-9') | typeof import('eslint-8') = require(eslintPath);\n\n let eslint: TEslint | TEslintLegacy;\n const majorVersion: number = parseInt(eslintVersion, 10);\n if (majorVersion < 9) {\n eslint = new ESLint({ cwd, useEslintrc: true });\n } else {\n eslint = new ESLint({ cwd });\n }\n\n let results: (TEslint.LintResult | TEslintLegacy.LintResult)[];\n try {\n results = await eslint.lintFiles(files);\n } catch (e) {\n throw new Error(`@rushstack/eslint-bulk execution error: ${e.message}`);\n }\n\n const { write, prune } = await import('../bulk-suppressions-patch');\n switch (mode) {\n case 'suppress': {\n await write();\n break;\n }\n\n case 'prune': {\n await prune();\n break;\n }\n }\n\n if (results.length > 0) {\n const stylishFormatter: TEslint.Formatter | TEslintLegacy.Formatter = await eslint.loadFormatter();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const formattedResults: string = await Promise.resolve(stylishFormatter.format(results as any));\n console.log(formattedResults);\n }\n\n console.log(\n '@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json ' +\n `files under directory ${cwd}`\n );\n}\n"]}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=start.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/start.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,44 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const prune_1 = require("./prune");
const suppress_1 = require("./suppress");
const is_correct_cwd_1 = require("./utils/is-correct-cwd");
const print_help_1 = require("./utils/print-help");
if (process.argv.includes('-h') || process.argv.includes('-H') || process.argv.includes('--help')) {
(0, print_help_1.printHelp)();
process.exit(0);
}
if (process.argv.length < 3) {
(0, print_help_1.printHelp)();
process.exit(1);
}
if (!(0, is_correct_cwd_1.isCorrectCwd)(process.cwd())) {
console.error('@rushstack/eslint-bulk: Please call this command from the directory that contains .eslintrc.js or .eslintrc.cjs');
process.exit(1);
}
const subcommand = process.argv[2];
let processPromise;
switch (subcommand) {
case 'suppress': {
processPromise = (0, suppress_1.suppressAsync)();
break;
}
case 'prune': {
processPromise = (0, prune_1.pruneAsync)();
break;
}
default: {
console.error('@rushstack/eslint-bulk: Unknown subcommand: ' + subcommand);
process.exit(1);
}
}
processPromise.catch((e) => {
if (e instanceof Error) {
console.error(e.message);
process.exit(1);
}
throw e;
});
//# sourceMappingURL=start.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/start.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,mCAAqC;AACrC,yCAA2C;AAC3C,2DAAsD;AACtD,mDAA+C;AAE/C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAClG,IAAA,sBAAS,GAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IAC5B,IAAA,sBAAS,GAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,IAAA,6BAAY,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;IACjC,OAAO,CAAC,KAAK,CACX,iHAAiH,CAClH,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,GAAW,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3C,IAAI,cAA6B,CAAC;AAClC,QAAQ,UAAU,EAAE,CAAC;IACnB,KAAK,UAAU,CAAC,CAAC,CAAC;QAChB,cAAc,GAAG,IAAA,wBAAa,GAAE,CAAC;QACjC,MAAM;IACR,CAAC;IAED,KAAK,OAAO,CAAC,CAAC,CAAC;QACb,cAAc,GAAG,IAAA,kBAAU,GAAE,CAAC;QAC9B,MAAM;IACR,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;QACR,OAAO,CAAC,KAAK,CAAC,8CAA8C,GAAG,UAAU,CAAC,CAAC;QAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACzB,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,CAAC;AACV,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { pruneAsync } from './prune';\nimport { suppressAsync } from './suppress';\nimport { isCorrectCwd } from './utils/is-correct-cwd';\nimport { printHelp } from './utils/print-help';\n\nif (process.argv.includes('-h') || process.argv.includes('-H') || process.argv.includes('--help')) {\n printHelp();\n process.exit(0);\n}\n\nif (process.argv.length < 3) {\n printHelp();\n process.exit(1);\n}\n\nif (!isCorrectCwd(process.cwd())) {\n console.error(\n '@rushstack/eslint-bulk: Please call this command from the directory that contains .eslintrc.js or .eslintrc.cjs'\n );\n process.exit(1);\n}\n\nconst subcommand: string = process.argv[2];\nlet processPromise: Promise<void>;\nswitch (subcommand) {\n case 'suppress': {\n processPromise = suppressAsync();\n break;\n }\n\n case 'prune': {\n processPromise = pruneAsync();\n break;\n }\n\n default: {\n console.error('@rushstack/eslint-bulk: Unknown subcommand: ' + subcommand);\n process.exit(1);\n }\n}\n\nprocessPromise.catch((e) => {\n if (e instanceof Error) {\n console.error(e.message);\n process.exit(1);\n }\n\n throw e;\n});\n"]}

View File

@@ -0,0 +1,2 @@
export declare function suppressAsync(): Promise<void>;
//# sourceMappingURL=suppress.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"suppress.d.ts","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/suppress.ts"],"names":[],"mappings":"AAaA,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAuEnD"}

View File

@@ -0,0 +1,63 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.suppressAsync = suppressAsync;
const print_help_1 = require("./utils/print-help");
const runEslint_1 = require("./runEslint");
const constants_1 = require("../constants");
async function suppressAsync() {
const args = process.argv.slice(3);
if (args.includes('--help') || args.includes('-h')) {
(0, print_help_1.printSuppressHelp)();
process.exit(0);
}
// Use reduce to create an object with all the parsed arguments
const parsedArgs = args.reduce((acc, arg, index, arr) => {
if (arg === '--rule') {
// continue because next arg should be the rule
}
else if (index > 0 && arr[index - 1] === '--rule' && arr[index + 1]) {
acc.rules.push(arg);
}
else if (arg === '--all') {
acc.all = true;
}
else if (arg.startsWith('--')) {
throw new Error(`@rushstack/eslint-bulk: Unknown option: ${arg}`);
}
else {
acc.files.push(arg);
}
return acc;
}, { rules: [], all: false, files: [] });
if (parsedArgs.files.length === 0) {
throw new Error('@rushstack/eslint-bulk: Files argument is required. Use glob patterns to specify files or use ' +
'`.` to suppress all files for the specified rules.');
}
if (parsedArgs.rules.length === 0 && !parsedArgs.all) {
throw new Error('@rushstack/eslint-bulk: Please specify at least one rule to suppress. Use --all to suppress all rules.');
}
// Find the index of the last argument that starts with '--'
const lastOptionIndex = args
.map((arg, i) => (arg.startsWith('--') ? i : -1))
.reduce((lastIndex, currentIndex) => Math.max(lastIndex, currentIndex), -1);
// Check if options come before files
if (parsedArgs.files.some((file) => args.indexOf(file) < lastOptionIndex)) {
throw new Error('@rushstack/eslint-bulk: Unable to parse command line arguments. All options should come before files argument.');
}
if (parsedArgs.all) {
process.env[constants_1.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME] = '*';
}
else if (parsedArgs.rules.length > 0) {
process.env[constants_1.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME] = parsedArgs.rules.join(',');
}
await (0, runEslint_1.runEslintAsync)(parsedArgs.files, 'suppress');
if (parsedArgs.all) {
console.log(`@rushstack/eslint-bulk: Successfully suppressed all rules for file(s) ${parsedArgs.files}`);
}
else if (parsedArgs.rules.length > 0) {
console.log(`@rushstack/eslint-bulk: Successfully suppressed rules ${parsedArgs.rules} for file(s) ${parsedArgs.files}`);
}
}
//# sourceMappingURL=suppress.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare function getEslintPathAndVersion(packagePath: string): [string, string];
//# sourceMappingURL=get-eslint-cli.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-eslint-cli.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts"],"names":[],"mappings":"AAmBA,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA8C7E"}

View File

@@ -0,0 +1,57 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEslintPathAndVersion = getEslintPathAndVersion;
const path_1 = __importDefault(require("path"));
const constants_1 = require("../../constants");
// When this list is updated, update the `eslint-bulk-suppressions-newest-test`
// and/or the `eslint-bulk-suppressions-newest-test` projects' eslint dependencies.
const TESTED_VERSIONS = new Set([
'8.6.0',
'8.7.0',
'8.21.0',
'8.22.0',
'8.23.0',
'8.23.1',
'8.57.0',
'9.25.1'
]);
function getEslintPathAndVersion(packagePath) {
// Try to find a local ESLint installation, the one that should be listed as a dev dependency in package.json
// and installed in node_modules
try {
const localEslintApiPath = require.resolve(constants_1.BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME, {
paths: [packagePath]
});
const localEslintPath = path_1.default.dirname(path_1.default.dirname(localEslintApiPath));
const { version: localEslintVersion } = require(`${localEslintPath}/package.json`);
if (!TESTED_VERSIONS.has(localEslintVersion)) {
console.warn('@rushstack/eslint-bulk: Be careful, the installed ESLint version has not been tested with eslint-bulk.');
}
return [localEslintApiPath, localEslintVersion];
}
catch (e1) {
try {
const { dependencies, devDependencies } = require(`${packagePath}/package.json`);
if (devDependencies === null || devDependencies === void 0 ? void 0 : devDependencies.eslint) {
throw new Error('@rushstack/eslint-bulk: eslint is specified as a dev dependency in package.json, ' +
'but eslint-bulk cannot find it in node_modules.');
}
else if (dependencies === null || dependencies === void 0 ? void 0 : dependencies.eslint) {
throw new Error('@rushstack/eslint-bulk: eslint is specified as a dependency in package.json, ' +
'but eslint-bulk cannot find it in node_modules.');
}
else {
throw new Error('@rushstack/eslint-bulk: eslint is not specified as a dependency in package.json.');
}
}
catch (e2) {
throw new Error("@rushstack/eslint-bulk: This command must be run in the same folder as a project's package.json file.");
}
}
}
//# sourceMappingURL=get-eslint-cli.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-eslint-cli.js","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;AAkB3D,0DA8CC;AA9DD,gDAAwB;AACxB,+CAA4E;AAE5E,+EAA+E;AAC/E,mFAAmF;AACnF,MAAM,eAAe,GAAgB,IAAI,GAAG,CAAC;IAC3C,OAAO;IACP,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAEH,SAAgB,uBAAuB,CAAC,WAAmB;IACzD,6GAA6G;IAC7G,gCAAgC;IAChC,IAAI,CAAC;QACH,MAAM,kBAAkB,GAAW,OAAO,CAAC,OAAO,CAAC,qDAAyC,EAAE;YAC5F,KAAK,EAAE,CAAC,WAAW,CAAC;SACrB,CAAC,CAAC;QACH,MAAM,eAAe,GAAW,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC/E,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,eAAe,eAAe,CAAC,CAAC;QAEnF,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC7C,OAAO,CAAC,IAAI,CACV,wGAAwG,CACzG,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,EACJ,YAAY,EACZ,eAAe,EAChB,GAGG,OAAO,CAAC,GAAG,WAAW,eAAe,CAAC,CAAC;YAE3C,IAAI,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CACb,mFAAmF;oBACjF,iDAAiD,CACpD,CAAC;YACJ,CAAC;iBAAM,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CACb,+EAA+E;oBAC7E,iDAAiD,CACpD,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;YACtG,CAAC;QACH,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,uGAAuG,CACxG,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport path from 'path';\nimport { BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME } from '../../constants';\n\n// When this list is updated, update the `eslint-bulk-suppressions-newest-test`\n// and/or the `eslint-bulk-suppressions-newest-test` projects' eslint dependencies.\nconst TESTED_VERSIONS: Set<string> = new Set([\n '8.6.0',\n '8.7.0',\n '8.21.0',\n '8.22.0',\n '8.23.0',\n '8.23.1',\n '8.57.0',\n '9.25.1'\n]);\n\nexport function getEslintPathAndVersion(packagePath: string): [string, string] {\n // Try to find a local ESLint installation, the one that should be listed as a dev dependency in package.json\n // and installed in node_modules\n try {\n const localEslintApiPath: string = require.resolve(BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME, {\n paths: [packagePath]\n });\n const localEslintPath: string = path.dirname(path.dirname(localEslintApiPath));\n const { version: localEslintVersion } = require(`${localEslintPath}/package.json`);\n\n if (!TESTED_VERSIONS.has(localEslintVersion)) {\n console.warn(\n '@rushstack/eslint-bulk: Be careful, the installed ESLint version has not been tested with eslint-bulk.'\n );\n }\n\n return [localEslintApiPath, localEslintVersion];\n } catch (e1) {\n try {\n const {\n dependencies,\n devDependencies\n }: {\n dependencies: Record<string, string> | undefined;\n devDependencies: Record<string, string> | undefined;\n } = require(`${packagePath}/package.json`);\n\n if (devDependencies?.eslint) {\n throw new Error(\n '@rushstack/eslint-bulk: eslint is specified as a dev dependency in package.json, ' +\n 'but eslint-bulk cannot find it in node_modules.'\n );\n } else if (dependencies?.eslint) {\n throw new Error(\n '@rushstack/eslint-bulk: eslint is specified as a dependency in package.json, ' +\n 'but eslint-bulk cannot find it in node_modules.'\n );\n } else {\n throw new Error('@rushstack/eslint-bulk: eslint is not specified as a dependency in package.json.');\n }\n } catch (e2) {\n throw new Error(\n \"@rushstack/eslint-bulk: This command must be run in the same folder as a project's package.json file.\"\n );\n }\n }\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare function isCorrectCwd(cwd: string): boolean;
//# sourceMappingURL=is-correct-cwd.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-correct-cwd.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/is-correct-cwd.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQjD"}

View File

@@ -0,0 +1,17 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCorrectCwd = isCorrectCwd;
const fs_1 = __importDefault(require("fs"));
function isCorrectCwd(cwd) {
return (fs_1.default.existsSync(`${cwd}/eslint.config.js`) ||
fs_1.default.existsSync(`${cwd}/eslint.config.cjs`) ||
fs_1.default.existsSync(`${cwd}/eslint.config.mjs`) ||
fs_1.default.existsSync(`${cwd}/.eslintrc.js`) ||
fs_1.default.existsSync(`${cwd}/.eslintrc.cjs`));
}
//# sourceMappingURL=is-correct-cwd.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-correct-cwd.js","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/is-correct-cwd.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;AAI3D,oCAQC;AAVD,4CAAoB;AAEpB,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,CACL,YAAE,CAAC,UAAU,CAAC,GAAG,GAAG,mBAAmB,CAAC;QACxC,YAAE,CAAC,UAAU,CAAC,GAAG,GAAG,oBAAoB,CAAC;QACzC,YAAE,CAAC,UAAU,CAAC,GAAG,GAAG,oBAAoB,CAAC;QACzC,YAAE,CAAC,UAAU,CAAC,GAAG,GAAG,eAAe,CAAC;QACpC,YAAE,CAAC,UAAU,CAAC,GAAG,GAAG,gBAAgB,CAAC,CACtC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport fs from 'fs';\n\nexport function isCorrectCwd(cwd: string): boolean {\n return (\n fs.existsSync(`${cwd}/eslint.config.js`) ||\n fs.existsSync(`${cwd}/eslint.config.cjs`) ||\n fs.existsSync(`${cwd}/eslint.config.mjs`) ||\n fs.existsSync(`${cwd}/.eslintrc.js`) ||\n fs.existsSync(`${cwd}/.eslintrc.cjs`)\n );\n}\n"]}

View File

@@ -0,0 +1,4 @@
export declare function printPruneHelp(): void;
export declare function printHelp(): void;
export declare function printSuppressHelp(): void;
//# sourceMappingURL=print-help.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"print-help.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/print-help.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,IAAI,IAAI,CAarC;AAED,wBAAgB,SAAS,IAAI,IAAI,CA8BhC;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CA6BxC"}

View File

@@ -0,0 +1,81 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.printPruneHelp = printPruneHelp;
exports.printHelp = printHelp;
exports.printSuppressHelp = printSuppressHelp;
const wrap_words_to_lines_1 = require("./wrap-words-to-lines");
function printPruneHelp() {
const help = `eslint-bulk prune
Usage:
eslint-bulk prune
This command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.`;
const wrapped = (0, wrap_words_to_lines_1.wrapWordsToLines)(help);
for (const line of wrapped) {
console.log(line);
}
}
function printHelp() {
const help = `eslint-bulk <command>
Usage:
eslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]
eslint-bulk suppress --all PATH1 [PATH2...]
eslint-bulk suppress --help
eslint-bulk prune
eslint-bulk prune --help
eslint-bulk --help
This command line tool is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to suppress or prune unused suppressions in the local .eslint-bulk-suppressions.json file.
Commands:
eslint-bulk suppress [options] <path...>
Use this command to generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.
Please run "eslint-bulk suppress --help" to learn more.
eslint-bulk prune
Use this command to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.
Please run "eslint-bulk prune --help" to learn more.
`;
const wrapped = (0, wrap_words_to_lines_1.wrapWordsToLines)(help);
for (const line of wrapped) {
console.log(line);
}
}
function printSuppressHelp() {
const help = `eslint-bulk suppress [options] <path...>
Usage:
eslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]
eslint-bulk suppress --all PATH1 [PATH2...]
eslint-bulk suppress --help
This command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to either generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.
Argument:
<path...>
Glob patterns for paths to suppress, same as eslint files argument. Should be relative to the project root.
Options:
-h, -H, --help
Display this help message.
-R, --rule
The full name of the ESLint rule you want to bulk-suppress. Specify multiple rules with --rule NAME1 --rule RULENAME2.
-A, --all
Bulk-suppress all rules in the specified file patterns.`;
const wrapped = (0, wrap_words_to_lines_1.wrapWordsToLines)(help);
for (const line of wrapped) {
console.log(line);
}
}
//# sourceMappingURL=print-help.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"print-help.js","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/print-help.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAI3D,wCAaC;AAED,8BA8BC;AAED,8CA6BC;AA9ED,+DAAyD;AAEzD,SAAgB,cAAc;IAC5B,MAAM,IAAI,GAAW;;;;;;sNAM+L,CAAC;IAErN,MAAM,OAAO,GAAa,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAgB,SAAS;IACvB,MAAM,IAAI,GAAW;;;;;;;;;;;;;;;;;;;;;;;CAuBtB,CAAC;IAEA,MAAM,OAAO,GAAa,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,IAAI,GAAW;;;;;;;;;;;;;;;;;;;;;;4DAsBqC,CAAC;IAE3D,MAAM,OAAO,GAAa,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { wrapWordsToLines } from './wrap-words-to-lines';\n\nexport function printPruneHelp(): void {\n const help: string = `eslint-bulk prune\n\nUsage:\n\neslint-bulk prune\n\nThis command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.`;\n\n const wrapped: string[] = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n\nexport function printHelp(): void {\n const help: string = `eslint-bulk <command>\n\nUsage:\n\neslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]\neslint-bulk suppress --all PATH1 [PATH2...]\neslint-bulk suppress --help\n\neslint-bulk prune\neslint-bulk prune --help\n\neslint-bulk --help\n\nThis command line tool is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to suppress or prune unused suppressions in the local .eslint-bulk-suppressions.json file.\n\nCommands:\n eslint-bulk suppress [options] <path...>\n Use this command to generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.\n Please run \"eslint-bulk suppress --help\" to learn more.\n\n eslint-bulk prune\n Use this command to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.\n Please run \"eslint-bulk prune --help\" to learn more.\n`;\n\n const wrapped: string[] = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n\nexport function printSuppressHelp(): void {\n const help: string = `eslint-bulk suppress [options] <path...>\n\nUsage:\n\neslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]\neslint-bulk suppress --all PATH1 [PATH2...]\neslint-bulk suppress --help\n\nThis command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to either generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.\n\nArgument:\n <path...>\n Glob patterns for paths to suppress, same as eslint files argument. Should be relative to the project root.\n\nOptions:\n -h, -H, --help\n Display this help message.\n\n -R, --rule\n The full name of the ESLint rule you want to bulk-suppress. Specify multiple rules with --rule NAME1 --rule RULENAME2.\n\n -A, --all\n Bulk-suppress all rules in the specified file patterns.`;\n\n const wrapped: string[] = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n"]}

View File

@@ -0,0 +1,26 @@
/**
* Applies word wrapping and returns an array of lines.
*
* @param text - The text to wrap
* @param maxLineLength - The maximum length of a line, defaults to the console width
* @param indent - The number of spaces to indent the wrapped lines, defaults to 0
*/
export declare function wrapWordsToLines(text: string, maxLineLength?: number, indent?: number): string[];
/**
* Applies word wrapping and returns an array of lines.
*
* @param text - The text to wrap
* @param maxLineLength - The maximum length of a line, defaults to the console width
* @param linePrefix - The string to prefix each line with, defaults to ''
*/
export declare function wrapWordsToLines(text: string, maxLineLength?: number, linePrefix?: string): string[];
/**
* Applies word wrapping and returns an array of lines.
*
* @param text - The text to wrap
* @param maxLineLength - The maximum length of a line, defaults to the console width
* @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix
* each line with, defaults to no prefix
*/
export declare function wrapWordsToLines(text: string, maxLineLength?: number, indentOrLinePrefix?: number | string): string[];
//# sourceMappingURL=wrap-words-to-lines.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"wrap-words-to-lines.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/wrap-words-to-lines.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AAClG;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AACtG;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,aAAa,CAAC,EAAE,MAAM,EACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,GACnC,MAAM,EAAE,CAAC"}

View File

@@ -0,0 +1,68 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapWordsToLines = wrapWordsToLines;
function wrapWordsToLines(text, maxLineLength, indentOrLinePrefix) {
var _a;
let linePrefix;
switch (typeof indentOrLinePrefix) {
case 'number':
linePrefix = ' '.repeat(indentOrLinePrefix);
break;
case 'string':
linePrefix = indentOrLinePrefix;
break;
default:
linePrefix = '';
break;
}
const linePrefixLength = linePrefix.length;
if (!maxLineLength) {
maxLineLength = process.stdout.getWindowSize()[0];
}
// Apply word wrapping and the provided line prefix, while also respecting existing newlines
// and prefix spaces that may exist in the text string already.
const lines = text.split(/\r?\n/);
const wrappedLines = [];
for (const line of lines) {
if (line.length + linePrefixLength <= maxLineLength) {
wrappedLines.push(linePrefix + line);
}
else {
const lineAdditionalPrefix = ((_a = line.match(/^\s*/)) === null || _a === void 0 ? void 0 : _a[0]) || '';
const whitespaceRegexp = /\s+/g;
let currentWhitespaceMatch = null;
let previousWhitespaceMatch;
let currentLineStartIndex = lineAdditionalPrefix.length;
let previousBreakRanOver = false;
while ((currentWhitespaceMatch = whitespaceRegexp.exec(line)) !== null) {
if (currentWhitespaceMatch.index + linePrefixLength - currentLineStartIndex > maxLineLength) {
let whitespaceToSplitAt;
if (!previousWhitespaceMatch ||
// Handle the case where there are two words longer than the maxLineLength in a row
previousBreakRanOver) {
whitespaceToSplitAt = currentWhitespaceMatch;
}
else {
whitespaceToSplitAt = previousWhitespaceMatch;
}
wrappedLines.push(linePrefix +
lineAdditionalPrefix +
line.substring(currentLineStartIndex, whitespaceToSplitAt.index));
previousBreakRanOver = whitespaceToSplitAt.index - currentLineStartIndex > maxLineLength;
currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;
}
else {
previousBreakRanOver = false;
}
previousWhitespaceMatch = currentWhitespaceMatch;
}
if (currentLineStartIndex < line.length) {
wrappedLines.push(linePrefix + lineAdditionalPrefix + line.substring(currentLineStartIndex));
}
}
}
return wrappedLines;
}
//# sourceMappingURL=wrap-words-to-lines.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
export declare const ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_PATCH_PATH';
export declare const ESLINT_BULK_SUPPRESS_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_SUPPRESS';
export declare const ESLINT_BULK_ENABLE_ENV_VAR_NAME: 'ESLINT_BULK_ENABLE';
export declare const ESLINT_BULK_PRUNE_ENV_VAR_NAME: 'ESLINT_BULK_PRUNE';
export declare const ESLINT_BULK_DETECT_ENV_VAR_NAME: '_RUSHSTACK_ESLINT_BULK_DETECT';
export declare const ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_FORCE_REGENERATE_PATCH';
export declare const VSCODE_PID_ENV_VAR_NAME: 'VSCODE_PID';
export declare const ESLINT_PACKAGE_NAME_ENV_VAR_NAME: '_RUSHSTACK_ESLINT_PACKAGE_NAME';
export declare const BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME: string;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mCAAmC,EAAE,kCACd,CAAC;AACrC,eAAO,MAAM,iCAAiC,EAAE,gCACd,CAAC;AACnC,eAAO,MAAM,+BAA+B,EAAE,oBAA2C,CAAC;AAC1F,eAAO,MAAM,8BAA8B,EAAE,mBAAyC,CAAC;AACvF,eAAO,MAAM,+BAA+B,EAAE,+BACb,CAAC;AAClC,eAAO,MAAM,+CAA+C,EAAE,8CACd,CAAC;AACjD,eAAO,MAAM,uBAAuB,EAAE,YAA2B,CAAC;AAElE,eAAO,MAAM,gCAAgC,EAAE,gCACb,CAAC;AAEnC,eAAO,MAAM,yCAAyC,EAAE,MACG,CAAC"}

View File

@@ -0,0 +1,16 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME = exports.ESLINT_PACKAGE_NAME_ENV_VAR_NAME = exports.VSCODE_PID_ENV_VAR_NAME = exports.ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME = exports.ESLINT_BULK_DETECT_ENV_VAR_NAME = exports.ESLINT_BULK_PRUNE_ENV_VAR_NAME = exports.ESLINT_BULK_ENABLE_ENV_VAR_NAME = exports.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME = exports.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME = void 0;
exports.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME = 'RUSHSTACK_ESLINT_BULK_PATCH_PATH';
exports.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME = 'RUSHSTACK_ESLINT_BULK_SUPPRESS';
exports.ESLINT_BULK_ENABLE_ENV_VAR_NAME = 'ESLINT_BULK_ENABLE';
exports.ESLINT_BULK_PRUNE_ENV_VAR_NAME = 'ESLINT_BULK_PRUNE';
exports.ESLINT_BULK_DETECT_ENV_VAR_NAME = '_RUSHSTACK_ESLINT_BULK_DETECT';
exports.ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME = 'RUSHSTACK_ESLINT_BULK_FORCE_REGENERATE_PATCH';
exports.VSCODE_PID_ENV_VAR_NAME = 'VSCODE_PID';
exports.ESLINT_PACKAGE_NAME_ENV_VAR_NAME = '_RUSHSTACK_ESLINT_PACKAGE_NAME';
exports.BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME = (_a = process.env[exports.ESLINT_PACKAGE_NAME_ENV_VAR_NAME]) !== null && _a !== void 0 ? _a : 'eslint';
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;AAE9C,QAAA,mCAAmC,GAC9C,kCAAkC,CAAC;AACxB,QAAA,iCAAiC,GAC5C,gCAAgC,CAAC;AACtB,QAAA,+BAA+B,GAAyB,oBAAoB,CAAC;AAC7E,QAAA,8BAA8B,GAAwB,mBAAmB,CAAC;AAC1E,QAAA,+BAA+B,GAC1C,+BAA+B,CAAC;AACrB,QAAA,+CAA+C,GAC1D,8CAA8C,CAAC;AACpC,QAAA,uBAAuB,GAAiB,YAAY,CAAC;AAErD,QAAA,gCAAgC,GAC3C,gCAAgC,CAAC;AAEtB,QAAA,yCAAyC,GACpD,MAAA,OAAO,CAAC,GAAG,CAAC,wCAAgC,CAAC,mCAAI,QAAQ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport const ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_PATCH_PATH' =\n 'RUSHSTACK_ESLINT_BULK_PATCH_PATH';\nexport const ESLINT_BULK_SUPPRESS_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_SUPPRESS' =\n 'RUSHSTACK_ESLINT_BULK_SUPPRESS';\nexport const ESLINT_BULK_ENABLE_ENV_VAR_NAME: 'ESLINT_BULK_ENABLE' = 'ESLINT_BULK_ENABLE';\nexport const ESLINT_BULK_PRUNE_ENV_VAR_NAME: 'ESLINT_BULK_PRUNE' = 'ESLINT_BULK_PRUNE';\nexport const ESLINT_BULK_DETECT_ENV_VAR_NAME: '_RUSHSTACK_ESLINT_BULK_DETECT' =\n '_RUSHSTACK_ESLINT_BULK_DETECT';\nexport const ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_FORCE_REGENERATE_PATCH' =\n 'RUSHSTACK_ESLINT_BULK_FORCE_REGENERATE_PATCH';\nexport const VSCODE_PID_ENV_VAR_NAME: 'VSCODE_PID' = 'VSCODE_PID';\n\nexport const ESLINT_PACKAGE_NAME_ENV_VAR_NAME: '_RUSHSTACK_ESLINT_PACKAGE_NAME' =\n '_RUSHSTACK_ESLINT_PACKAGE_NAME';\n\nexport const BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME: string =\n process.env[ESLINT_PACKAGE_NAME_ENV_VAR_NAME] ?? 'eslint';\n"]}

View File

@@ -0,0 +1,7 @@
/**
* Dynamically generate file to properly patch many versions of ESLint
* @param inputFilePath - Must be an iteration of https://github.com/eslint/eslint/blob/main/lib/linter/linter.js
* @param outputFilePath - Some small changes to linter.js
*/
export declare function generatePatchedLinterJsFileIfDoesNotExist(inputFilePath: string, outputFilePath: string, eslintPackageVersion: string): void;
//# sourceMappingURL=generate-patched-file.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"generate-patched-file.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/generate-patched-file.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,oBAAoB,EAAE,MAAM,GAC3B,IAAI,CAkTN"}

View File

@@ -0,0 +1,283 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePatchedLinterJsFileIfDoesNotExist = generatePatchedLinterJsFileIfDoesNotExist;
const fs_1 = __importDefault(require("fs"));
const constants_1 = require("./constants");
/**
* Dynamically generate file to properly patch many versions of ESLint
* @param inputFilePath - Must be an iteration of https://github.com/eslint/eslint/blob/main/lib/linter/linter.js
* @param outputFilePath - Some small changes to linter.js
*/
function generatePatchedLinterJsFileIfDoesNotExist(inputFilePath, outputFilePath, eslintPackageVersion) {
const generateEnvVarValue = process.env[constants_1.ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME];
if (generateEnvVarValue !== 'true' && generateEnvVarValue !== '1' && fs_1.default.existsSync(outputFilePath)) {
return;
}
const majorVersion = parseInt(eslintPackageVersion, 10);
const inputFile = fs_1.default.readFileSync(inputFilePath).toString();
let inputIndex = 0;
/**
* Extract from the stream until marker is reached. When matching marker,
* ignore whitespace in the stream and in the marker. Return the extracted text.
*/
function scanUntilMarker(marker) {
const trimmedMarker = marker.replace(/\s/g, '');
let output = '';
let trimmed = '';
while (inputIndex < inputFile.length) {
const char = inputFile[inputIndex++];
output += char;
if (!/^\s$/.test(char)) {
trimmed += char;
}
if (trimmed.endsWith(trimmedMarker)) {
return output;
}
}
throw new Error('Unexpected end of input while looking for ' + JSON.stringify(marker));
}
function scanUntilNewline() {
let output = '';
while (inputIndex < inputFile.length) {
const char = inputFile[inputIndex++];
output += char;
if (char === '\n') {
return output;
}
}
throw new Error('Unexpected end of input while looking for new line');
}
function scanUntilEnd() {
const output = inputFile.substring(inputIndex);
inputIndex = inputFile.length;
return output;
}
const markerForStartOfClassMethodSpaces = '\n */\n ';
const markerForStartOfClassMethodTabs = '\n\t */\n\t';
function indexOfStartOfClassMethod(input, position) {
let startOfClassMethodIndex = input.indexOf(markerForStartOfClassMethodSpaces, position);
if (startOfClassMethodIndex === -1) {
startOfClassMethodIndex = input.indexOf(markerForStartOfClassMethodTabs, position);
if (startOfClassMethodIndex === -1) {
return { index: startOfClassMethodIndex };
}
return { index: startOfClassMethodIndex, marker: markerForStartOfClassMethodTabs };
}
return { index: startOfClassMethodIndex, marker: markerForStartOfClassMethodSpaces };
}
/**
* Returns index of next public method
* @param fromIndex - index of inputFile to search if public method still exists
* @returns -1 if public method does not exist or index of next public method
*/
function getIndexOfNextMethod(fromIndex) {
const rest = inputFile.substring(fromIndex);
const endOfClassIndex = rest.indexOf('\n}');
const { index: startOfClassMethodIndex, marker: startOfClassMethodMarker } = indexOfStartOfClassMethod(rest);
if (startOfClassMethodIndex === -1 ||
!startOfClassMethodMarker ||
startOfClassMethodIndex > endOfClassIndex) {
return { index: -1 };
}
const afterMarkerIndex = startOfClassMethodIndex + startOfClassMethodMarker.length;
const isPublicMethod = rest[afterMarkerIndex] !== '_' &&
rest[afterMarkerIndex] !== '#' &&
!rest.substring(afterMarkerIndex, rest.indexOf('\n', afterMarkerIndex)).includes('static') &&
!rest.substring(afterMarkerIndex, rest.indexOf('\n', afterMarkerIndex)).includes('constructor');
return { index: fromIndex + afterMarkerIndex, isPublic: isPublicMethod };
}
function scanUntilIndex(indexToScanTo) {
const output = inputFile.substring(inputIndex, indexToScanTo);
inputIndex = indexToScanTo;
return output;
}
let outputFile = '';
// Match this:
// //------------------------------------------------------------------------------
// // Requirements
// //------------------------------------------------------------------------------
outputFile += scanUntilMarker('// Requirements');
outputFile += scanUntilMarker('//--');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
const bulkSuppressionsPatch = require(process.env.${constants_1.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME});
const requireFromPathToLinterJS = bulkSuppressionsPatch.requireFromPathToLinterJS;
`;
// Match this:
// //------------------------------------------------------------------------------
// // Typedefs
// //------------------------------------------------------------------------------
const requireSection = scanUntilMarker('// Typedefs');
// Match something like this:
//
// const path = require('path'),
// eslintScope = require('eslint-scope'),
// evk = require('eslint-visitor-keys'),
//
// Convert to something like this:
//
// const path = require('path'),
// eslintScope = requireFromPathToLinterJS('eslint-scope'),
// evk = requireFromPathToLinterJS('eslint-visitor-keys'),
//
outputFile += requireSection.replace(/require\s*\((?:'([^']+)'|"([^"]+)")\)/g, (match, p1, p2) => {
var _a;
const importPath = (_a = p1 !== null && p1 !== void 0 ? p1 : p2) !== null && _a !== void 0 ? _a : '';
if (importPath !== 'path') {
if (p1) {
return `requireFromPathToLinterJS('${p1}')`;
}
if (p2) {
return `requireFromPathToLinterJS("${p2}")`;
}
}
// Keep as-is
return match;
});
outputFile += `--- END MONKEY PATCH ---
`;
if (majorVersion >= 9) {
outputFile += scanUntilMarker('const emitter = createEmitter();');
outputFile += `
// --- BEGIN MONKEY PATCH ---
let currentNode = undefined;
// --- END MONKEY PATCH ---`;
}
// Match this:
// ```
// if (reportTranslator === null) {
// reportTranslator = createReportTranslator({
// ruleId,
// severity,
// sourceCode,
// messageIds,
// disableFixes
// });
// }
// const problem = reportTranslator(...args);
//
// if (problem.fix && !(rule.meta && rule.meta.fixable)) {
// throw new Error("Fixable rules must set the `meta.fixable` property to \"code\" or \"whitespace\".");
// }
// ```
//
// Convert to something like this:
// ```
// if (reportTranslator === null) {
// reportTranslator = createReportTranslator({
// ruleId,
// severity,
// sourceCode,
// messageIds,
// disableFixes
// });
// }
// const problem = reportTranslator(...args);
// // --- BEGIN MONKEY PATCH ---
// if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode: args[0]?.node ?? currentNode, ruleId, problem })) return;
// // --- END MONKEY PATCH ---
//
// if (problem.fix && !(rule.meta && rule.meta.fixable)) {
// throw new Error("Fixable rules must set the `meta.fixable` property to \"code\" or \"whitespace\".");
// }
// ```
outputFile += scanUntilMarker('const problem = reportTranslator(...args);');
outputFile += `
// --- BEGIN MONKEY PATCH ---
if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode: args[0]?.node ?? currentNode, ruleId, problem })) return;
// --- END MONKEY PATCH ---`;
//
// Match this:
// ```
// Object.keys(ruleListeners).forEach(selector => {
// ...
// });
// ```
//
// Convert to something like this:
// ```
// Object.keys(ruleListeners).forEach(selector => {
// // --- BEGIN MONKEY PATCH ---
// emitter.on(selector, (...args) => { currentNode = args[args.length - 1]; });
// // --- END MONKEY PATCH ---
// ...
// });
// ```
if (majorVersion >= 9) {
outputFile += scanUntilMarker('Object.keys(ruleListeners).forEach(selector => {');
outputFile += `
// --- BEGIN MONKEY PATCH ---
emitter.on(selector, (...args) => { currentNode = args[args.length - 1]; });
// --- END MONKEY PATCH ---`;
}
outputFile += scanUntilMarker('class Linter {');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
/**
* We intercept ESLint execution at the .eslintrc.js file, but unfortunately the Linter class is
* initialized before the .eslintrc.js file is executed. This means the internalSlotsMap that all
* the patched methods refer to is not initialized. This method checks if the internalSlotsMap is
* initialized, and if not, initializes it.
*/
_conditionallyReinitialize({ cwd, configType } = {}) {
if (internalSlotsMap.get(this) === undefined) {
internalSlotsMap.set(this, {
cwd: normalizeCwd(cwd),
lastConfigArray: null,
lastSourceCode: null,
lastSuppressedMessages: [],
configType, // TODO: Remove after flat config conversion
parserMap: new Map([['espree', espree]]),
ruleMap: new Rules()
});
this.version = pkg.version;
}
}
// --- END MONKEY PATCH ---
`;
const privateMethodNames = [];
let { index: indexOfNextMethod, isPublic } = getIndexOfNextMethod(inputIndex);
while (indexOfNextMethod !== -1) {
outputFile += scanUntilIndex(indexOfNextMethod);
if (isPublic) {
// Inject the monkey patch at the start of the public method
outputFile += scanUntilNewline();
outputFile += ` // --- BEGIN MONKEY PATCH ---
this._conditionallyReinitialize();
// --- END MONKEY PATCH ---
`;
}
else if (inputFile[inputIndex] === '#') {
// Replace the '#' private method with a '_' private method, so that our monkey patch
// can still call it. Otherwise, we get the following error during execution:
// TypeError: Receiver must be an instance of class Linter
const privateMethodName = scanUntilMarker('(');
// Remove the '(' at the end and stash it, since we need to escape it for the regex later
privateMethodNames.push(privateMethodName.slice(0, -1));
outputFile += `_${privateMethodName.slice(1)}`;
}
const indexResult = getIndexOfNextMethod(inputIndex);
indexOfNextMethod = indexResult.index;
isPublic = indexResult.isPublic;
}
outputFile += scanUntilEnd();
// Do a second pass to find and replace all calls to private methods with the patched versions.
if (privateMethodNames.length) {
// eslint-disable-next-line @rushstack/security/no-unsafe-regexp
const privateMethodCallRegex = new RegExp(`\.(${privateMethodNames.join('|')})\\(`, 'g');
outputFile = outputFile.replace(privateMethodCallRegex, (match, privateMethodName) => {
// Replace the leading '#' with a leading '_'
return `._${privateMethodName.slice(1)}(`;
});
}
fs_1.default.writeFileSync(outputFilePath, outputFile);
}
//# sourceMappingURL=generate-patched-file.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/index.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,27 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const _patch_base_1 = require("../_patch-base");
const path_utils_1 = require("./path-utils");
const bulk_suppressions_patch_1 = require("./bulk-suppressions-patch");
const generate_patched_file_1 = require("./generate-patched-file");
const constants_1 = require("./constants");
if (!_patch_base_1.eslintFolder) {
console.error('@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.');
process.exit(1);
}
const eslintBulkDetectEnvVarValue = process.env[constants_1.ESLINT_BULK_DETECT_ENV_VAR_NAME];
if (eslintBulkDetectEnvVarValue === 'true' || eslintBulkDetectEnvVarValue === '1') {
(0, path_utils_1.findAndConsoleLogPatchPathCli)();
process.exit(0);
}
const pathToLinterJS = (0, path_utils_1.getPathToLinterJS)();
process.env[constants_1.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME] = require.resolve('./bulk-suppressions-patch');
const pathToGeneratedPatch = (0, path_utils_1.ensurePathToGeneratedPatch)();
(0, generate_patched_file_1.generatePatchedLinterJsFileIfDoesNotExist)(pathToLinterJS, pathToGeneratedPatch, _patch_base_1.eslintPackageVersion);
const { Linter: LinterPatch } = require(pathToGeneratedPatch);
LinterPatch.prototype.verify = (0, bulk_suppressions_patch_1.extendVerifyFunction)(LinterPatch.prototype.verify);
const { Linter } = require(pathToLinterJS);
(0, bulk_suppressions_patch_1.patchClass)(Linter, LinterPatch);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,gDAAoE;AACpE,6CAA4G;AAC5G,uEAA6E;AAC7E,mEAAoF;AACpF,2CAAmG;AAEnG,IAAI,CAAC,0BAAY,EAAE,CAAC;IAClB,OAAO,CAAC,KAAK,CACX,gGAAgG,CACjG,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,2BAA2B,GAAuB,OAAO,CAAC,GAAG,CAAC,2CAA+B,CAAC,CAAC;AACrG,IAAI,2BAA2B,KAAK,MAAM,IAAI,2BAA2B,KAAK,GAAG,EAAE,CAAC;IAClF,IAAA,0CAA6B,GAAE,CAAC;IAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,cAAc,GAAW,IAAA,8BAAiB,GAAE,CAAC;AAEnD,OAAO,CAAC,GAAG,CAAC,+CAAmC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAEhG,MAAM,oBAAoB,GAAW,IAAA,uCAA0B,GAAE,CAAC;AAClE,IAAA,iEAAyC,EAAC,cAAc,EAAE,oBAAoB,EAAE,kCAAoB,CAAC,CAAC;AACtG,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC9D,WAAW,CAAC,SAAS,CAAC,MAAM,GAAG,IAAA,8CAAoB,EAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAElF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAE3C,IAAA,oCAAU,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { eslintFolder, eslintPackageVersion } from '../_patch-base';\nimport { findAndConsoleLogPatchPathCli, getPathToLinterJS, ensurePathToGeneratedPatch } from './path-utils';\nimport { patchClass, extendVerifyFunction } from './bulk-suppressions-patch';\nimport { generatePatchedLinterJsFileIfDoesNotExist } from './generate-patched-file';\nimport { ESLINT_BULK_DETECT_ENV_VAR_NAME, ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME } from './constants';\n\nif (!eslintFolder) {\n console.error(\n '@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.'\n );\n\n process.exit(1);\n}\n\nconst eslintBulkDetectEnvVarValue: string | undefined = process.env[ESLINT_BULK_DETECT_ENV_VAR_NAME];\nif (eslintBulkDetectEnvVarValue === 'true' || eslintBulkDetectEnvVarValue === '1') {\n findAndConsoleLogPatchPathCli();\n process.exit(0);\n}\n\nconst pathToLinterJS: string = getPathToLinterJS();\n\nprocess.env[ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME] = require.resolve('./bulk-suppressions-patch');\n\nconst pathToGeneratedPatch: string = ensurePathToGeneratedPatch();\ngeneratePatchedLinterJsFileIfDoesNotExist(pathToLinterJS, pathToGeneratedPatch, eslintPackageVersion);\nconst { Linter: LinterPatch } = require(pathToGeneratedPatch);\nLinterPatch.prototype.verify = extendVerifyFunction(LinterPatch.prototype.verify);\n\nconst { Linter } = require(pathToLinterJS);\n\npatchClass(Linter, LinterPatch);\n"]}

View File

@@ -0,0 +1,4 @@
export declare function findAndConsoleLogPatchPathCli(): void;
export declare function getPathToLinterJS(): string;
export declare function ensurePathToGeneratedPatch(): string;
//# sourceMappingURL=path-utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/path-utils.ts"],"names":[],"mappings":"AAgBA,wBAAgB,6BAA6B,IAAI,IAAI,CAqBpD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAKnD"}

View File

@@ -0,0 +1,48 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findAndConsoleLogPatchPathCli = findAndConsoleLogPatchPathCli;
exports.getPathToLinterJS = getPathToLinterJS;
exports.ensurePathToGeneratedPatch = ensurePathToGeneratedPatch;
const fs_1 = __importDefault(require("fs"));
const os_1 = __importDefault(require("os"));
const _patch_base_1 = require("../_patch-base");
const constants_1 = require("./constants");
const package_json_1 = __importDefault(require("../../package.json"));
const CURRENT_PACKAGE_VERSION = package_json_1.default.version;
function findAndConsoleLogPatchPathCli() {
const eslintBulkDetectEnvVarValue = process.env[constants_1.ESLINT_BULK_DETECT_ENV_VAR_NAME];
if (eslintBulkDetectEnvVarValue !== 'true' && eslintBulkDetectEnvVarValue !== '1') {
return;
}
const startDelimiter = 'RUSHSTACK_ESLINT_BULK_START';
const endDelimiter = 'RUSHSTACK_ESLINT_BULK_END';
const configuration = {
/**
* `@rushstack/eslint-bulk` should report an error if its package.json is older than this number
*/
minCliVersion: '0.0.0',
/**
* `@rushstack/eslint-bulk` will invoke this entry point
*/
cliEntryPoint: require.resolve('../exports/eslint-bulk')
};
console.log(startDelimiter + JSON.stringify(configuration) + endDelimiter);
}
function getPathToLinterJS() {
if (!_patch_base_1.eslintFolder) {
throw new Error('Cannot find ESLint installation to patch.');
}
return `${_patch_base_1.eslintFolder}/lib/linter/linter.js`;
}
function ensurePathToGeneratedPatch() {
const patchesFolderPath = `${os_1.default.tmpdir()}/rushstack-eslint-bulk-${CURRENT_PACKAGE_VERSION}/patches`;
fs_1.default.mkdirSync(patchesFolderPath, { recursive: true });
const pathToGeneratedPatch = `${patchesFolderPath}/linter-patch-v${_patch_base_1.eslintPackageVersion}.js`;
return pathToGeneratedPatch;
}
//# sourceMappingURL=path-utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/path-utils.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;AAe3D,sEAqBC;AAED,8CAMC;AAED,gEAKC;AAjDD,4CAAoB;AACpB,4CAAoB;AACpB,gDAAoE;AACpE,2CAA8D;AAC9D,sEAAoD;AAOpD,MAAM,uBAAuB,GAAW,sBAAkB,CAAC,OAAO,CAAC;AAEnE,SAAgB,6BAA6B;IAC3C,MAAM,2BAA2B,GAAuB,OAAO,CAAC,GAAG,CAAC,2CAA+B,CAAC,CAAC;IACrG,IAAI,2BAA2B,KAAK,MAAM,IAAI,2BAA2B,KAAK,GAAG,EAAE,CAAC;QAClF,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAW,6BAA6B,CAAC;IAC7D,MAAM,YAAY,GAAW,2BAA2B,CAAC;IAEzD,MAAM,aAAa,GAAmB;QACpC;;WAEG;QACH,aAAa,EAAE,OAAO;QACtB;;WAEG;QACH,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC;KACzD,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC,CAAC;AAC7E,CAAC;AAED,SAAgB,iBAAiB;IAC/B,IAAI,CAAC,0BAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,GAAG,0BAAY,uBAAuB,CAAC;AAChD,CAAC;AAED,SAAgB,0BAA0B;IACxC,MAAM,iBAAiB,GAAW,GAAG,YAAE,CAAC,MAAM,EAAE,0BAA0B,uBAAuB,UAAU,CAAC;IAC5G,YAAE,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,oBAAoB,GAAW,GAAG,iBAAiB,kBAAkB,kCAAoB,KAAK,CAAC;IACrG,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport fs from 'fs';\nimport os from 'os';\nimport { eslintFolder, eslintPackageVersion } from '../_patch-base';\nimport { ESLINT_BULK_DETECT_ENV_VAR_NAME } from './constants';\nimport currentPackageJson from '../../package.json';\n\ninterface IConfiguration {\n minCliVersion: string;\n cliEntryPoint: string;\n}\n\nconst CURRENT_PACKAGE_VERSION: string = currentPackageJson.version;\n\nexport function findAndConsoleLogPatchPathCli(): void {\n const eslintBulkDetectEnvVarValue: string | undefined = process.env[ESLINT_BULK_DETECT_ENV_VAR_NAME];\n if (eslintBulkDetectEnvVarValue !== 'true' && eslintBulkDetectEnvVarValue !== '1') {\n return;\n }\n\n const startDelimiter: string = 'RUSHSTACK_ESLINT_BULK_START';\n const endDelimiter: string = 'RUSHSTACK_ESLINT_BULK_END';\n\n const configuration: IConfiguration = {\n /**\n * `@rushstack/eslint-bulk` should report an error if its package.json is older than this number\n */\n minCliVersion: '0.0.0',\n /**\n * `@rushstack/eslint-bulk` will invoke this entry point\n */\n cliEntryPoint: require.resolve('../exports/eslint-bulk')\n };\n\n console.log(startDelimiter + JSON.stringify(configuration) + endDelimiter);\n}\n\nexport function getPathToLinterJS(): string {\n if (!eslintFolder) {\n throw new Error('Cannot find ESLint installation to patch.');\n }\n\n return `${eslintFolder}/lib/linter/linter.js`;\n}\n\nexport function ensurePathToGeneratedPatch(): string {\n const patchesFolderPath: string = `${os.tmpdir()}/rushstack-eslint-bulk-${CURRENT_PACKAGE_VERSION}/patches`;\n fs.mkdirSync(patchesFolderPath, { recursive: true });\n const pathToGeneratedPatch: string = `${patchesFolderPath}/linter-patch-v${eslintPackageVersion}.js`;\n return pathToGeneratedPatch;\n}\n"]}

View File

@@ -0,0 +1,2 @@
import '../eslint-bulk-suppressions/cli/start';
//# sourceMappingURL=eslint-bulk.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"eslint-bulk.d.ts","sourceRoot":"","sources":["../../src/exports/eslint-bulk.ts"],"names":[],"mappings":"AAKA,OAAO,uCAAuC,CAAC"}

View File

@@ -0,0 +1,7 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
// "lib/exports/eslint-bulk" is the entry point for the @rushstack/eslint-bulk command line front end.
require("../eslint-bulk-suppressions/cli/start");
//# sourceMappingURL=eslint-bulk.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"eslint-bulk.js","sourceRoot":"","sources":["../../src/exports/eslint-bulk.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,sGAAsG;AAEtG,iDAA+C","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n// \"lib/exports/eslint-bulk\" is the entry point for the @rushstack/eslint-bulk command line front end.\n\nimport '../eslint-bulk-suppressions/cli/start';\n"]}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=modern-module-resolution.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"modern-module-resolution.d.ts","sourceRoot":"","sources":["../src/modern-module-resolution.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,69 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
// This is a workaround for https://github.com/eslint/eslint/issues/3458
//
// To correct how ESLint searches for plugin packages, add this line to the top of your project's .eslintrc.js file:
//
// require("@rushstack/eslint-patch/modern-module-resolution");
//
const _patch_base_1 = require("./_patch-base");
// error: "The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''"
const isInvalidImporterPath = (ex) => (ex === null || ex === void 0 ? void 0 : ex.code) === 'ERR_INVALID_ARG_VALUE';
if (!_patch_base_1.configArrayFactory.__loadPluginPatched) {
_patch_base_1.configArrayFactory.__loadPluginPatched = true;
// eslint-disable-next-line @typescript-eslint/typedef
const originalLoadPlugin = _patch_base_1.configArrayFactory.prototype._loadPlugin;
if (_patch_base_1.ESLINT_MAJOR_VERSION === 6) {
// ESLint 6.x
// https://github.com/eslint/eslint/blob/9738f8cc864d769988ccf42bb70f524444df1349/lib/cli-engine/config-array-factory.js#L915
_patch_base_1.configArrayFactory.prototype._loadPlugin = function (name, importerPath, importerName) {
const originalResolve = _patch_base_1.ModuleResolver.resolve;
try {
_patch_base_1.ModuleResolver.resolve = function (moduleName, relativeToPath) {
try {
// resolve using importerPath instead of relativeToPath
return originalResolve.call(this, moduleName, importerPath);
}
catch (e) {
if ((0, _patch_base_1.isModuleResolutionError)(e) || isInvalidImporterPath(e)) {
return originalResolve.call(this, moduleName, relativeToPath);
}
throw e;
}
};
return originalLoadPlugin.apply(this, arguments);
}
finally {
_patch_base_1.ModuleResolver.resolve = originalResolve;
}
};
}
else {
// ESLint 7.x || 8.x
// https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L1023
_patch_base_1.configArrayFactory.prototype._loadPlugin = function (name, ctx) {
const originalResolve = _patch_base_1.ModuleResolver.resolve;
try {
_patch_base_1.ModuleResolver.resolve = function (moduleName, relativeToPath) {
try {
// resolve using ctx.filePath instead of relativeToPath
return originalResolve.call(this, moduleName, ctx.filePath);
}
catch (e) {
if ((0, _patch_base_1.isModuleResolutionError)(e) || isInvalidImporterPath(e)) {
return originalResolve.call(this, moduleName, relativeToPath);
}
throw e;
}
};
return originalLoadPlugin.apply(this, arguments);
}
finally {
_patch_base_1.ModuleResolver.resolve = originalResolve;
}
};
}
}
//# sourceMappingURL=modern-module-resolution.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=usage.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC"}

View File

@@ -0,0 +1,7 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
throw new Error('The @rushstack/eslint-patch package does not have a default entry point.' +
' See README.md for usage instructions.');
//# sourceMappingURL=usage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,MAAM,IAAI,KAAK,CACb,0EAA0E;IACxE,wCAAwC,CAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nthrow new Error(\n 'The @rushstack/eslint-patch package does not have a default entry point.' +\n ' See README.md for usage instructions.'\n);\n\nexport {};\n"]}

View File

@@ -0,0 +1 @@
require('./lib/modern-module-resolution');

View File

@@ -0,0 +1,42 @@
{
"name": "@rushstack/eslint-patch",
"version": "1.12.0",
"description": "Enhance ESLint with better support for large scale monorepos",
"main": "lib/usage.js",
"license": "MIT",
"repository": {
"url": "https://github.com/microsoft/rushstack.git",
"type": "git",
"directory": "eslint/eslint-patch"
},
"homepage": "https://rushstack.io",
"keywords": [
"eslintrc",
"config",
"module",
"resolve",
"resolver",
"plugin",
"relative",
"package",
"bulk",
"suppressions",
"monorepo",
"monkey",
"patch"
],
"devDependencies": {
"@rushstack/heft": "0.73.2",
"@types/eslint-8": "npm:@types/eslint@8.56.10",
"@types/eslint-9": "npm:@types/eslint@9.6.1",
"@typescript-eslint/types": "~8.31.0",
"eslint-9": "npm:eslint@~9.25.1",
"eslint-8": "npm:eslint@~8.57.0",
"typescript": "~5.8.2",
"decoupled-local-node-rig": "1.0.0"
},
"scripts": {
"build": "heft build --clean",
"_phase:build": "heft run --only build -- --clean"
}
}