Tracking de l'application VApp (IHM du jeu)

This commit is contained in:
2025-05-11 18:04:12 +02:00
commit 89e9db9b62
17763 changed files with 3718499 additions and 0 deletions

24
VApp/node_modules/@rushstack/eslint-patch/LICENSE generated vendored Normal file
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.

252
VApp/node_modules/@rushstack/eslint-patch/README.md generated vendored Normal file
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,12 @@
declare const isModuleResolutionError: (ex: unknown) => boolean;
declare let eslintFolder: string | undefined;
declare const eslintMajorVersion: number;
declare let ConfigArrayFactory: any;
declare let ModuleResolver: {
resolve: any;
};
declare let Naming: {
normalizePackageName: any;
};
export { eslintFolder, ConfigArrayFactory, ModuleResolver, Naming, eslintMajorVersion as 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;AAoB1G,QAAA,IAAI,YAAY,EAAE,MAAM,GAAG,SAAqB,CAAC;AAuKjD,QAAA,MAAM,kBAAkB,EAAE,MAA2C,CAAC;AAgBtE,QAAA,IAAI,kBAAkB,EAAE,GAAG,CAAC;AAO5B,QAAA,IAAI,cAAc,EAAE;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC;AACrC,QAAA,IAAI,MAAM,EAAE;IAAE,oBAAoB,EAAE,GAAG,CAAA;CAAE,CAAC;AAS1C,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,MAAM,EACN,kBAAkB,IAAI,oBAAoB,EAC1C,uBAAuB,EACxB,CAAC"}

View File

@ -0,0 +1,205 @@
"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.isModuleResolutionError = exports.ESLINT_MAJOR_VERSION = exports.Naming = exports.ModuleResolver = exports.ConfigArrayFactory = exports.eslintFolder = 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 = require('path');
const fs = require('fs');
const isModuleResolutionError = (ex) => typeof ex === 'object' && !!ex && 'code' in ex && ex.code === 'MODULE_NOT_FOUND';
exports.isModuleResolutionError = isModuleResolutionError;
// 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 >=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 eslintrcFolder = path.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.join(eslintrcFolder, '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 rethrown.
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.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.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 rethrown.
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.dirname(require.resolve('@eslint/eslintrc/package.json', {
paths: [currentModule.path]
}));
const resolvedConfigArrayFactoryPath = path.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 rethrown.
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.dirname(require.resolve('eslint/package.json', {
paths: [currentModule.path]
}));
if (path.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.join(path.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.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 eslintPackageJson = fs.readFileSync(eslintPackageJsonPath).toString();
const eslintPackageObject = JSON.parse(eslintPackageJson);
const eslintPackageVersion = eslintPackageObject.version;
const eslintMajorVersion = parseInt(eslintPackageVersion, 10);
exports.ESLINT_MAJOR_VERSION = eslintMajorVersion;
if (isNaN(eslintMajorVersion)) {
throw new Error(`Unable to parse ESLint version "${eslintPackageVersion}" in file "${eslintPackageJsonPath}"`);
}
if (!(eslintMajorVersion >= 6 && eslintMajorVersion <= 8)) {
throw new Error('The ESLint patch script has only been tested with ESLint version 6.x, 7.x, and 8.x.' +
` (Your version: ${eslintPackageVersion})\n` +
'Consider reporting a GitHub issue:\n' +
'https://github.com/microsoft/rushstack/issues');
}
let ConfigArrayFactory;
if (eslintMajorVersion === 8) {
exports.ConfigArrayFactory = ConfigArrayFactory = require(eslintrcBundlePath).Legacy.ConfigArrayFactory;
}
else {
exports.ConfigArrayFactory = ConfigArrayFactory = require(configArrayFactoryPath).ConfigArrayFactory;
}
let ModuleResolver;
let Naming;
if (eslintMajorVersion === 8) {
exports.ModuleResolver = ModuleResolver = require(eslintrcBundlePath).Legacy.ModuleResolver;
exports.Naming = Naming = require(eslintrcBundlePath).Legacy.naming;
}
else {
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,46 @@
"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;
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,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,GAAG,4BAAc,CAAC,OAAO,CAAC;QAC/C,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 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) {\n const originalResolve = ModuleResolver.resolve;\n try {\n ModuleResolver.resolve = function (moduleName: string, relativeToPath: 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 ClassExpressionWithName extends TSESTree.ClassExpression {
id: TSESTree.Identifier;
}
export declare function isClassExpressionWithName(node: TSESTree.Node): node is ClassExpressionWithName;
export interface FunctionExpressionWithName extends TSESTree.FunctionExpression {
id: TSESTree.Identifier;
}
export declare function isFunctionExpressionWithName(node: TSESTree.Node): node is FunctionExpressionWithName;
export type NormalAnonymousExpression = TSESTree.ArrowFunctionExpression | TSESTree.ClassExpression | TSESTree.FunctionExpression | TSESTree.ObjectExpression;
export declare function isNormalAnonymousExpression(node: TSESTree.Node): node is NormalAnonymousExpression;
export interface NormalAssignmentPattern extends TSESTree.AssignmentPattern {
left: TSESTree.Identifier;
}
export declare function isNormalAssignmentPattern(node: TSESTree.Node): node is NormalAssignmentPattern;
export interface NormalClassPropertyDefinition extends TSESTree.PropertyDefinitionNonComputedName {
key: TSESTree.PrivateIdentifier | TSESTree.Identifier;
value: TSESTree.Expression;
}
export declare function isNormalClassPropertyDefinition(node: TSESTree.Node): node is NormalClassPropertyDefinition;
export interface NormalMethodDefinition extends TSESTree.MethodDefinitionNonComputedName {
key: TSESTree.PrivateIdentifier | TSESTree.Identifier;
}
export declare function isNormalMethodDefinition(node: TSESTree.Node): node is NormalMethodDefinition;
export interface NormalObjectProperty extends TSESTree.PropertyNonComputedName {
key: TSESTree.Identifier;
}
export declare function isNormalObjectProperty(node: TSESTree.Node): node is NormalObjectProperty;
export interface NormalVariableDeclarator extends TSESTree.VariableDeclarator {
id: TSESTree.Identifier;
init: TSESTree.Expression;
}
export declare function isNormalVariableDeclarator(node: TSESTree.Node): node is NormalVariableDeclarator;
export interface NormalAssignmentPatternWithAnonymousExpressionAssigned extends NormalAssignmentPattern {
right: NormalAnonymousExpression;
}
export declare function isNormalAssignmentPatternWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalAssignmentPatternWithAnonymousExpressionAssigned;
export interface NormalVariableDeclaratorWithAnonymousExpressionAssigned extends NormalVariableDeclarator {
init: NormalAnonymousExpression;
}
export declare function isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalVariableDeclaratorWithAnonymousExpressionAssigned;
export interface NormalObjectPropertyWithAnonymousExpressionAssigned extends NormalObjectProperty {
value: NormalAnonymousExpression;
}
export declare function isNormalObjectPropertyWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalObjectPropertyWithAnonymousExpressionAssigned;
export interface NormalClassPropertyDefinitionWithAnonymousExpressionAssigned extends NormalClassPropertyDefinition {
value: NormalAnonymousExpression;
}
export declare function isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalClassPropertyDefinitionWithAnonymousExpressionAssigned;
export type NodeWithName = TSESTree.ClassDeclarationWithName | TSESTree.FunctionDeclarationWithName | ClassExpressionWithName | FunctionExpressionWithName | NormalVariableDeclaratorWithAnonymousExpressionAssigned | NormalObjectPropertyWithAnonymousExpressionAssigned | NormalClassPropertyDefinitionWithAnonymousExpressionAssigned | NormalAssignmentPatternWithAnonymousExpressionAssigned | NormalMethodDefinition | 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,uBAAwB,SAAQ,QAAQ,CAAC,eAAe;IACvE,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC;CACzB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,uBAAuB,CAE9F;AACD,MAAM,WAAW,0BAA2B,SAAQ,QAAQ,CAAC,kBAAkB;IAC7E,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC;CACzB;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,0BAA0B,CAEpG;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,uBAAwB,SAAQ,QAAQ,CAAC,iBAAiB;IACzE,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC3B;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,uBAAuB,CAE9F;AAED,MAAM,WAAW,6BAA8B,SAAQ,QAAQ,CAAC,iCAAiC;IAC/F,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,6BAA6B,CAM1G;AAED,MAAM,WAAW,sBAAuB,SAAQ,QAAQ,CAAC,+BAA+B;IACtF,GAAG,EAAE,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC;CACvD;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,sBAAsB,CAE5F;AAED,MAAM,WAAW,oBAAqB,SAAQ,QAAQ,CAAC,uBAAuB;IAC5E,GAAG,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC1B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,oBAAoB,CAExF;AAED,MAAM,WAAW,wBAAyB,SAAQ,QAAQ,CAAC,kBAAkB;IAC3E,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC;IACxB,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;CAC3B;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,wBAAwB,CAEhG;AAED,MAAM,WAAW,sDAAuD,SAAQ,uBAAuB;IACrG,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,wDAAwD,CACtE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,sDAAsD,CAEhE;AAED,MAAM,WAAW,uDAAwD,SAAQ,wBAAwB;IACvG,IAAI,EAAE,yBAAyB,CAAC;CACjC;AAED,wBAAgB,yDAAyD,CACvE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,uDAAuD,CAEjE;AAED,MAAM,WAAW,mDAAoD,SAAQ,oBAAoB;IAC/F,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,qDAAqD,CACnE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,mDAAmD,CAE7D;AAED,MAAM,WAAW,4DACf,SAAQ,6BAA6B;IACrC,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,8DAA8D,CAC5E,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,4DAA4D,CAEtE;AAED,MAAM,MAAM,YAAY,GACpB,QAAQ,CAAC,wBAAwB,GACjC,QAAQ,CAAC,2BAA2B,GACpC,uBAAuB,GACvB,0BAA0B,GAC1B,uDAAuD,GACvD,mDAAmD,GACnD,4DAA4D,GAC5D,sDAAsD,GACtD,sBAAsB,GACtB,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,191 @@
"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.isNodeWithName = exports.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned = exports.isNormalObjectPropertyWithAnonymousExpressionAssigned = exports.isNormalVariableDeclaratorWithAnonymousExpressionAssigned = exports.isNormalAssignmentPatternWithAnonymousExpressionAssigned = exports.isNormalVariableDeclarator = exports.isNormalObjectProperty = exports.isNormalMethodDefinition = exports.isNormalClassPropertyDefinition = exports.isNormalAssignmentPattern = exports.isNormalAnonymousExpression = exports.isFunctionExpressionWithName = exports.isClassExpressionWithName = exports.isStringLiteral = exports.isPropertyNameNonComputed = exports.isNumberLiteral = exports.isFunctionDeclarationWithName = exports.isClassPropertyNameNonComputed = exports.isClassDeclarationWithName = exports.isVariableDeclarator = exports.isTSTypeAliasDeclaration = exports.isTSQualifiedName = exports.isTSModuleDeclaration = exports.isTSInterfaceDeclaration = exports.isTSEnumDeclaration = exports.isPropertyDefinition = exports.isProperty = exports.isPrivateIdentifier = exports.isObjectExpression = exports.isMethodDefinition = exports.isLiteral = exports.isIdentifier = exports.isFunctionExpression = exports.isFunctionDeclaration = exports.isExpression = exports.isExportDefaultDeclaration = exports.isClassExpression = exports.isClassDeclaration = exports.isAssignmentPattern = exports.isArrowFunctionExpression = exports.isArrayExpression = void 0;
function isArrayExpression(node) {
return node.type === 'ArrayExpression';
}
exports.isArrayExpression = isArrayExpression;
function isArrowFunctionExpression(node) {
return node.type === 'ArrowFunctionExpression';
}
exports.isArrowFunctionExpression = isArrowFunctionExpression;
/** default parameters */
function isAssignmentPattern(node) {
return node.type === 'AssignmentPattern';
}
exports.isAssignmentPattern = isAssignmentPattern;
function isClassDeclaration(node) {
return node.type === 'ClassDeclaration';
}
exports.isClassDeclaration = isClassDeclaration;
function isClassExpression(node) {
return node.type === 'ClassExpression';
}
exports.isClassExpression = isClassExpression;
function isExportDefaultDeclaration(node) {
return node.type === 'ExportDefaultDeclaration';
}
exports.isExportDefaultDeclaration = isExportDefaultDeclaration;
function isExpression(node) {
return node.type.includes('Expression');
}
exports.isExpression = isExpression;
function isFunctionDeclaration(node) {
return node.type === 'FunctionDeclaration';
}
exports.isFunctionDeclaration = isFunctionDeclaration;
function isFunctionExpression(node) {
return node.type === 'FunctionExpression';
}
exports.isFunctionExpression = isFunctionExpression;
function isIdentifier(node) {
return node.type === 'Identifier';
}
exports.isIdentifier = isIdentifier;
function isLiteral(node) {
return node.type === 'Literal';
}
exports.isLiteral = isLiteral;
function isMethodDefinition(node) {
return node.type === 'MethodDefinition';
}
exports.isMethodDefinition = isMethodDefinition;
function isObjectExpression(node) {
return node.type === 'ObjectExpression';
}
exports.isObjectExpression = isObjectExpression;
function isPrivateIdentifier(node) {
return node.type === 'PrivateIdentifier';
}
exports.isPrivateIdentifier = isPrivateIdentifier;
function isProperty(node) {
return node.type === 'Property';
}
exports.isProperty = isProperty;
function isPropertyDefinition(node) {
return node.type === 'PropertyDefinition';
}
exports.isPropertyDefinition = isPropertyDefinition;
function isTSEnumDeclaration(node) {
return node.type === 'TSEnumDeclaration';
}
exports.isTSEnumDeclaration = isTSEnumDeclaration;
function isTSInterfaceDeclaration(node) {
return node.type === 'TSInterfaceDeclaration';
}
exports.isTSInterfaceDeclaration = isTSInterfaceDeclaration;
function isTSModuleDeclaration(node) {
return node.type === 'TSModuleDeclaration';
}
exports.isTSModuleDeclaration = isTSModuleDeclaration;
function isTSQualifiedName(node) {
return node.type === 'TSQualifiedName';
}
exports.isTSQualifiedName = isTSQualifiedName;
function isTSTypeAliasDeclaration(node) {
return node.type === 'TSTypeAliasDeclaration';
}
exports.isTSTypeAliasDeclaration = isTSTypeAliasDeclaration;
function isVariableDeclarator(node) {
return node.type === 'VariableDeclarator';
}
exports.isVariableDeclarator = isVariableDeclarator;
// Compound Type Guards for @typescript-eslint/types ast-spec compound types
function isClassDeclarationWithName(node) {
return isClassDeclaration(node) && node.id !== null;
}
exports.isClassDeclarationWithName = isClassDeclarationWithName;
function isClassPropertyNameNonComputed(node) {
return isPrivateIdentifier(node) || isPropertyNameNonComputed(node);
}
exports.isClassPropertyNameNonComputed = isClassPropertyNameNonComputed;
function isFunctionDeclarationWithName(node) {
return isFunctionDeclaration(node) && node.id !== null;
}
exports.isFunctionDeclarationWithName = isFunctionDeclarationWithName;
function isNumberLiteral(node) {
return isLiteral(node) && typeof node.value === 'number';
}
exports.isNumberLiteral = isNumberLiteral;
function isPropertyNameNonComputed(node) {
return isIdentifier(node) || isNumberLiteral(node) || isStringLiteral(node);
}
exports.isPropertyNameNonComputed = isPropertyNameNonComputed;
function isStringLiteral(node) {
return isLiteral(node) && typeof node.value === 'string';
}
exports.isStringLiteral = isStringLiteral;
function isClassExpressionWithName(node) {
return isClassExpression(node) && node.id !== null;
}
exports.isClassExpressionWithName = isClassExpressionWithName;
function isFunctionExpressionWithName(node) {
return isFunctionExpression(node) && node.id !== null;
}
exports.isFunctionExpressionWithName = isFunctionExpressionWithName;
function isNormalAnonymousExpression(node) {
const ANONYMOUS_EXPRESSION_GUARDS = [
isArrowFunctionExpression,
isClassExpression,
isFunctionExpression,
isObjectExpression
];
return ANONYMOUS_EXPRESSION_GUARDS.some((guard) => guard(node));
}
exports.isNormalAnonymousExpression = isNormalAnonymousExpression;
function isNormalAssignmentPattern(node) {
return isAssignmentPattern(node) && isIdentifier(node.left);
}
exports.isNormalAssignmentPattern = isNormalAssignmentPattern;
function isNormalClassPropertyDefinition(node) {
return (isPropertyDefinition(node) &&
(isIdentifier(node.key) || isPrivateIdentifier(node.key)) &&
node.value !== null);
}
exports.isNormalClassPropertyDefinition = isNormalClassPropertyDefinition;
function isNormalMethodDefinition(node) {
return isMethodDefinition(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
exports.isNormalMethodDefinition = isNormalMethodDefinition;
function isNormalObjectProperty(node) {
return isProperty(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
exports.isNormalObjectProperty = isNormalObjectProperty;
function isNormalVariableDeclarator(node) {
return isVariableDeclarator(node) && isIdentifier(node.id) && node.init !== null;
}
exports.isNormalVariableDeclarator = isNormalVariableDeclarator;
function isNormalAssignmentPatternWithAnonymousExpressionAssigned(node) {
return isNormalAssignmentPattern(node) && isNormalAnonymousExpression(node.right);
}
exports.isNormalAssignmentPatternWithAnonymousExpressionAssigned = isNormalAssignmentPatternWithAnonymousExpressionAssigned;
function isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node) {
return isNormalVariableDeclarator(node) && isNormalAnonymousExpression(node.init);
}
exports.isNormalVariableDeclaratorWithAnonymousExpressionAssigned = isNormalVariableDeclaratorWithAnonymousExpressionAssigned;
function isNormalObjectPropertyWithAnonymousExpressionAssigned(node) {
return isNormalObjectProperty(node) && isNormalAnonymousExpression(node.value);
}
exports.isNormalObjectPropertyWithAnonymousExpressionAssigned = isNormalObjectPropertyWithAnonymousExpressionAssigned;
function isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node) {
return isNormalClassPropertyDefinition(node) && isNormalAnonymousExpression(node.value);
}
exports.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned = isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned;
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));
}
exports.isNodeWithName = isNodeWithName;
//# sourceMappingURL=ast-guards.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
import { TSESTree } from '@typescript-eslint/types';
/**
* @throws Throws an error if the command to retrieve the root path fails.
* @returns The root path of the monorepo.
*/
export declare function getGitRootPath(): string;
export declare const GitRootPath: string;
export declare function shouldBulkSuppress(params: {
filename: string;
currentNode: TSESTree.Node;
ruleId: string;
}): boolean;
export declare function onFinish(params: {
filename: string;
}): void;
export declare function BulkSuppressionsPrune(params: {
filename: string;
}): void;
export declare function requireFromPathToLinterJS(importPath: string): any;
export declare function patchClass<T, U extends T>(originalClass: new () => T, patchedClass: new () => U): void;
//# 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,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AA4DpD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED,eAAO,MAAM,WAAW,QAAmB,CAAC;AAuJ5C,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAqBV;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAI3D;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAWxE;AAGD,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAOjE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,UAAU,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,GAAG,IAAI,CAkBtG"}

View File

@ -0,0 +1,273 @@
"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 (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.patchClass = exports.requireFromPathToLinterJS = exports.BulkSuppressionsPrune = exports.onFinish = exports.shouldBulkSuppress = exports.GitRootPath = exports.getGitRootPath = void 0;
const child_process_1 = require("child_process");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const Guards = __importStar(require("./ast-guards"));
const _patch_base_1 = require("../_patch-base");
function getNodeName(node) {
if (!Guards.isNodeWithName(node))
return null;
if (Guards.isClassDeclarationWithName(node))
return node.id.name;
if (Guards.isFunctionDeclarationWithName(node))
return node.id.name;
if (Guards.isClassExpressionWithName(node))
return node.id.name;
if (Guards.isFunctionExpressionWithName(node))
return node.id.name;
if (Guards.isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node))
return node.id.name;
if (Guards.isNormalObjectPropertyWithAnonymousExpressionAssigned(node))
return node.key.name;
if (Guards.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node))
return node.key.name;
if (Guards.isNormalAssignmentPatternWithAnonymousExpressionAssigned(node))
return node.left.name;
if (Guards.isNormalMethodDefinition(node))
return node.key.name;
if (Guards.isTSEnumDeclaration(node))
return node.id.name;
if (Guards.isTSInterfaceDeclaration(node))
return node.id.name;
if (Guards.isTSTypeAliasDeclaration(node))
return node.id.name;
return null;
}
function calculateScopeId(node) {
const scopeIds = [];
for (let current = node; current; current = current.parent) {
const scopeIdForASTNode = getNodeName(current);
if (scopeIdForASTNode !== null)
scopeIds.unshift(scopeIdForASTNode);
}
if (scopeIds.length === 0)
return '.';
return '.' + scopeIds.join('.');
}
/**
* @throws Throws an error if the command to retrieve the root path fails.
* @returns The root path of the monorepo.
*/
function getGitRootPath() {
const result = (0, child_process_1.spawnSync)('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8' });
if (result.status !== 0)
throw new Error(`get root path failed`);
return result.stdout.toString().trim();
}
exports.getGitRootPath = getGitRootPath;
exports.GitRootPath = getGitRootPath();
function findEslintrcDirectory(fileAbsolutePath) {
for (let currentDir = fileAbsolutePath; currentDir.startsWith(exports.GitRootPath); currentDir = path_1.default.dirname(currentDir))
if (['.eslintrc.js', '.eslintrc.cjs'].some((eslintrc) => fs_1.default.existsSync(path_1.default.join(currentDir, eslintrc))))
return currentDir;
throw new Error('Cannot locate eslintrc');
}
function validateSuppressionsJson(json) {
if (typeof json !== 'object')
throw new Error(`Invalid JSON object: ${JSON.stringify(json, null, 2)}`);
if (json === null)
throw new Error('JSON object is null.');
if (!json.hasOwnProperty('suppressions'))
throw new Error('Missing "suppressions" property.');
if (!Array.isArray(json.suppressions))
throw new Error('"suppressions" property is not an array.');
if (!json.suppressions.every((suppression) => {
if (typeof suppression !== 'object')
throw new Error(`Invalid suppression: ${JSON.stringify(suppression, null, 2)}`);
if (suppression === null)
throw new Error(`Suppression is null: ${JSON.stringify(suppression, null, 2)}`);
if (!suppression.hasOwnProperty('file'))
throw new Error(`Missing "file" property in suppression: ${JSON.stringify(suppression, null, 2)}`);
if (typeof suppression.file !== 'string')
throw new Error(`"file" property in suppression is not a string: ${JSON.stringify(suppression, null, 2)}`);
if (!suppression.hasOwnProperty('scopeId'))
throw new Error(`Missing "scopeId" property in suppression: ${JSON.stringify(suppression, null, 2)}`);
if (typeof suppression.scopeId !== 'string')
throw new Error(`"scopeId" property in suppression is not a string: ${JSON.stringify(suppression, null, 2)}`);
if (!suppression.hasOwnProperty('rule'))
throw new Error(`Missing "rule" property in suppression: ${JSON.stringify(suppression, null, 2)}`);
if (typeof suppression.rule !== 'string')
throw new Error(`"rule" property in suppression is not a string: ${JSON.stringify(suppression, null, 2)}`);
return true;
})) {
throw new Error(`Invalid suppression in "suppressions" array: ${JSON.stringify(json.suppressions, null, 2)}`);
}
return true;
}
function readSuppressionsJson(fileAbsolutePath) {
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const suppressionsPath = path_1.default.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
let suppressionsJson = { suppressions: [] };
try {
const fileContent = fs_1.default.readFileSync(suppressionsPath, 'utf-8');
suppressionsJson = JSON.parse(fileContent);
if (!validateSuppressionsJson(suppressionsJson)) {
console.warn(`Unexpected file content in .eslint-bulk-suppressions.json. JSON expected to be in the following format:
{
suppressions: {
file: string;
scopeId: string;
rule: string;
}[];
}
Please check file content, or delete file if suppressions are no longer needed.
`);
suppressionsJson = { suppressions: [] };
}
}
catch (_a) {
// Do nothing and let JSON.parse() log the error. suppressionsJson will stay as the initialized value.
}
return suppressionsJson;
}
function shouldWriteSuppression(fileAbsolutePath, suppression) {
if (process.env.ESLINT_BULK_SUPPRESS === undefined)
return false;
if (isSuppressed(fileAbsolutePath, suppression))
return false;
const rulesToSuppress = process.env.ESLINT_BULK_SUPPRESS.split(',');
if (rulesToSuppress.length === 1 && rulesToSuppress[0] === '*')
return true;
return rulesToSuppress.includes(suppression.rule);
}
function isSuppressed(fileAbsolutePath, suppression) {
const suppressionsJson = readSuppressionsJson(fileAbsolutePath);
return (suppressionsJson.suppressions.find((element) => element.file === suppression.file &&
element.scopeId === suppression.scopeId &&
element.rule === suppression.rule) !== undefined);
}
function insort(array, item, compareFunction) {
const index = array.findIndex((element) => compareFunction(element, item) > 0);
if (index === -1)
array.push(item);
else
array.splice(index, 0, item);
}
function compareSuppressions(a, b) {
if (a.file < b.file)
return -1;
if (a.file > b.file)
return 1;
if (a.scopeId < b.scopeId)
return -1;
if (a.scopeId > b.scopeId)
return 1;
if (a.rule < b.rule)
return -1;
if (a.rule > b.rule)
return 1;
return 0;
}
function writeSuppressionToFile(fileAbsolutePath, suppression) {
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const suppressionsJson = readSuppressionsJson(fileAbsolutePath);
insort(suppressionsJson.suppressions, suppression, compareSuppressions);
const suppressionsPath = path_1.default.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
fs_1.default.writeFileSync(suppressionsPath, JSON.stringify(suppressionsJson, null, 2));
}
const usedSuppressions = new Set();
function serializeSuppression(fileAbsolutePath, suppression) {
return `${fileAbsolutePath}|${suppression.file}|${suppression.scopeId}|${suppression.rule}`;
}
function deserializeSuppression(serializedSuppression) {
const [file, scopeId, rule] = serializedSuppression.split('|');
return { file, scopeId, rule };
}
// 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.ESLINT_BULK_ENABLE === 'false')
return false;
const { filename: fileAbsolutePath, currentNode, ruleId: rule } = params;
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const fileRelativePath = path_1.default.relative(eslintrcDirectory, fileAbsolutePath);
const scopeId = calculateScopeId(currentNode);
const suppression = { file: fileRelativePath, scopeId, rule };
if (shouldWriteSuppression(fileAbsolutePath, suppression)) {
writeSuppressionToFile(fileAbsolutePath, suppression);
}
const shouldBulkSuppress = isSuppressed(fileAbsolutePath, suppression);
if (shouldBulkSuppress) {
usedSuppressions.add(serializeSuppression(fileAbsolutePath, suppression));
}
return shouldBulkSuppress;
}
exports.shouldBulkSuppress = shouldBulkSuppress;
function onFinish(params) {
if (process.env.ESLINT_BULK_PRUNE === 'true') {
BulkSuppressionsPrune(params);
}
}
exports.onFinish = onFinish;
function BulkSuppressionsPrune(params) {
const { filename: fileAbsolutePath } = params;
const suppressionsJson = readSuppressionsJson(fileAbsolutePath);
const newSuppressionsJson = {
suppressions: suppressionsJson.suppressions.filter((suppression) => {
return usedSuppressions.has(serializeSuppression(fileAbsolutePath, suppression));
})
};
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const suppressionsPath = path_1.default.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
fs_1.default.writeFileSync(suppressionsPath, JSON.stringify(newSuppressionsJson, null, 2));
}
exports.BulkSuppressionsPrune = BulkSuppressionsPrune;
// 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 = path_1.default.join(_patch_base_1.eslintFolder, 'lib', 'linter');
const moduleAbsolutePath = require.resolve(importPath, { paths: [pathToLinterFolder] });
return require(moduleAbsolutePath);
}
exports.requireFromPathToLinterJS = requireFromPathToLinterJS;
function patchClass(originalClass, patchedClass) {
// Get all the property names of the patched class prototype
let patchedProperties = Object.getOwnPropertyNames(patchedClass.prototype);
// Loop through all the properties
for (let prop of patchedProperties) {
// Override the property in the original class
originalClass.prototype[prop] = patchedClass.prototype[prop];
}
// Handle getters and setters
let descriptors = Object.getOwnPropertyDescriptors(patchedClass.prototype);
for (let prop in descriptors) {
let descriptor = descriptors[prop];
if (descriptor.get || descriptor.set) {
Object.defineProperty(originalClass.prototype, prop, descriptor);
}
}
}
exports.patchClass = patchClass;
//# 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 prune(): 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":"AAOA,wBAAgB,KAAK,SAsCpB"}

View File

@ -0,0 +1,35 @@
"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.prune = void 0;
const child_process_1 = require("child_process");
const get_eslint_cli_1 = require("./utils/get-eslint-cli");
const print_help_1 = require("./utils/print-help");
function prune() {
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 eslintCLI = (0, get_eslint_cli_1.getEslintCli)(process.cwd());
const env = Object.assign(Object.assign({}, process.env), { ESLINT_BULK_PRUNE: 'true' });
(0, child_process_1.exec)(`${eslintCLI} . --format=json`, { env }, (error, stdout, stderr) => {
// if errorCount != 0, ESLint will process.exit(1) giving the false impression
// that the exec failed, even though linting errors are to be expected
const eslintOutputWithErrorRegex = /"errorCount":(?!0)\d+/;
const isEslintError = error !== null && error.code === 1 && eslintOutputWithErrorRegex.test(stdout);
if (error && !isEslintError) {
throw new Error(`@rushstack/eslint-bulk execution error: ${error.message}`);
}
if (stderr) {
throw new Error(`@rushstack/eslint-bulk ESLint errors: ${stderr}`);
}
console.log(`@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json files under directory ${process.cwd()}`);
});
}
exports.prune = prune;
//# 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;;;AAE3D,iDAAoD;AACpD,2DAAsD;AACtD,mDAAoD;AAEpD,SAAgB,KAAK;IACnB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,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,SAAS,GAAG,IAAA,6BAAY,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE9C,MAAM,GAAG,mCAA2B,OAAO,CAAC,GAAG,KAAE,iBAAiB,EAAE,MAAM,GAAE,CAAC;IAE7E,IAAA,oBAAI,EACF,GAAG,SAAS,kBAAkB,EAC9B,EAAE,GAAG,EAAE,EACP,CAAC,KAA2B,EAAE,MAAc,EAAE,MAAc,EAAE,EAAE;QAC9D,8EAA8E;QAC9E,sEAAsE;QACtE,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;QAC3D,MAAM,aAAa,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEpG,IAAI,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,2CAA2C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,CAAC,GAAG,CACT,+HAA+H,OAAO,CAAC,GAAG,EAAE,EAAE,CAC/I,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAtCD,sBAsCC","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 { ExecException, exec } from 'child_process';\nimport { getEslintCli } from './utils/get-eslint-cli';\nimport { printPruneHelp } from './utils/print-help';\n\nexport function prune() {\n const args = 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 eslintCLI = getEslintCli(process.cwd());\n\n const env: NodeJS.ProcessEnv = { ...process.env, ESLINT_BULK_PRUNE: 'true' };\n\n exec(\n `${eslintCLI} . --format=json`,\n { env },\n (error: ExecException | null, stdout: string, stderr: string) => {\n // if errorCount != 0, ESLint will process.exit(1) giving the false impression\n // that the exec failed, even though linting errors are to be expected\n const eslintOutputWithErrorRegex = /\"errorCount\":(?!0)\\d+/;\n const isEslintError = error !== null && error.code === 1 && eslintOutputWithErrorRegex.test(stdout);\n\n if (error && !isEslintError) {\n throw new Error(`@rushstack/eslint-bulk execution error: ${error.message}`);\n }\n\n if (stderr) {\n throw new Error(`@rushstack/eslint-bulk ESLint errors: ${stderr}`);\n }\n\n console.log(\n `@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json files under directory ${process.cwd()}`\n );\n }\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,50 @@
"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];
if (subcommand === 'suppress') {
try {
(0, suppress_1.suppress)();
}
catch (e) {
if (e instanceof Error) {
console.error(e.message);
process.exit(1);
}
throw e;
}
}
else if (subcommand === 'prune') {
try {
(0, prune_1.prune)();
}
catch (e) {
if (e instanceof Error) {
console.error(e.message);
process.exit(1);
}
throw e;
}
}
else {
console.error('@rushstack/eslint-bulk: Unknown subcommand: ' + subcommand);
process.exit(1);
}
//# 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,mCAAgC;AAChC,yCAAsC;AACtC,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;AACD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,IAAA,mBAAQ,GAAE,CAAC;IACb,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;KAAM,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;IAClC,IAAI,CAAC;QACH,IAAA,aAAK,GAAE,CAAC;IACV,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,CAAC,8CAA8C,GAAG,UAAU,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,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 { prune } from './prune';\nimport { suppress } 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}\nconst subcommand = process.argv[2];\n\nif (subcommand === 'suppress') {\n try {\n suppress();\n } catch (e) {\n if (e instanceof Error) {\n console.error(e.message);\n process.exit(1);\n }\n throw e;\n }\n} else if (subcommand === 'prune') {\n try {\n prune();\n } catch (e) {\n if (e instanceof Error) {\n console.error(e.message);\n process.exit(1);\n }\n throw e;\n }\n} else {\n console.error('@rushstack/eslint-bulk: Unknown subcommand: ' + subcommand);\n process.exit(1);\n}\n"]}

View File

@ -0,0 +1,2 @@
export declare function suppress(): 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":"AAOA,wBAAgB,QAAQ,SA4FvB"}

View File

@ -0,0 +1,76 @@
"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.suppress = void 0;
const child_process_1 = require("child_process");
const get_eslint_cli_1 = require("./utils/get-eslint-cli");
const print_help_1 = require("./utils/print-help");
function suppress() {
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.');
}
const eslintCLI = (0, get_eslint_cli_1.getEslintCli)(process.cwd());
// 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.');
}
const env = Object.assign({}, process.env);
if (parsedArgs.all) {
env.ESLINT_BULK_SUPPRESS = '*';
}
else if (parsedArgs.rules.length > 0) {
env.ESLINT_BULK_SUPPRESS = parsedArgs.rules.join(',');
}
(0, child_process_1.exec)(`${eslintCLI} ${parsedArgs.files.join(' ')} --format=json`, { env }, (error, stdout, stderr) => {
// if errorCount != 0, ESLint will process.exit(1) giving the false impression
// that the exec failed, even though linting errors are to be expected
const eslintOutputWithErrorRegex = /"errorCount":(?!0)\d+/;
const isEslintError = error !== null && error.code === 1 && eslintOutputWithErrorRegex.test(stdout);
if (error && !isEslintError) {
throw new Error(`@rushstack/eslint-bulk execution error: ${error.message}`);
}
if (stderr) {
throw new Error(`@rushstack/eslint-bulk ESLint errors: ${stderr}`);
}
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}`);
}
});
}
exports.suppress = suppress;
//# sourceMappingURL=suppress.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export declare function getEslintCli(packagePath: 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":"AAOA,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAqBxD"}

View File

@ -0,0 +1,30 @@
"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.getEslintCli = void 0;
const path_1 = __importDefault(require("path"));
const TESTED_VERSIONS = ['8.6.0', '8.7.0', '8.21.0', '8.22.0', '8.23.0', '8.23.1'];
function getEslintCli(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('eslint', { paths: [packagePath] });
const localEslintPath = path_1.default.dirname(path_1.default.dirname(localEslintApiPath));
const eslintPackageJson = require(path_1.default.join(localEslintPath, 'package.json'));
const localEslintVersion = eslintPackageJson.version;
const eslintExecutable = path_1.default.join(localEslintPath, 'bin', 'eslint.js');
if (!TESTED_VERSIONS.includes(localEslintVersion)) {
console.warn('@rushstack/eslint-bulk: Be careful, the installed ESLint version has not been tested with eslint-bulk.');
}
return `node ${eslintExecutable}`;
}
catch (e) {
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.');
}
}
exports.getEslintCli = getEslintCli;
//# 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;;;;;;AAE3D,gDAAwB;AAExB,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAEnF,SAAgB,YAAY,CAAC,WAAmB;IAC9C,6GAA6G;IAC7G,gCAAgC;IAChC,IAAI,CAAC;QACH,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC/E,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACvE,MAAM,iBAAiB,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;QAC9E,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC;QACrD,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QAExE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CACV,wGAAwG,CACzG,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,gBAAgB,EAAE,CAAC;IACpC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,kIAAkI,CACnI,CAAC;IACJ,CAAC;AACH,CAAC;AArBD,oCAqBC","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';\n\nconst TESTED_VERSIONS = ['8.6.0', '8.7.0', '8.21.0', '8.22.0', '8.23.0', '8.23.1'];\n\nexport function getEslintCli(packagePath: 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 = require.resolve('eslint', { paths: [packagePath] });\n const localEslintPath = path.dirname(path.dirname(localEslintApiPath));\n const eslintPackageJson = require(path.join(localEslintPath, 'package.json'));\n const localEslintVersion = eslintPackageJson.version;\n const eslintExecutable = path.join(localEslintPath, 'bin', 'eslint.js');\n\n if (!TESTED_VERSIONS.includes(localEslintVersion)) {\n console.warn(\n '@rushstack/eslint-bulk: Be careful, the installed ESLint version has not been tested with eslint-bulk.'\n );\n }\n return `node ${eslintExecutable}`;\n } catch (e) {\n throw new Error(\n '@rushstack/eslint-bulk: eslint is specified as a dev dependency in package.json, but eslint-bulk cannot find it in node_modules.'\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":"AAMA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD"}

View File

@ -0,0 +1,15 @@
"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 = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
function isCorrectCwd(cwd) {
return fs_1.default.existsSync(path_1.default.join(cwd, '.eslintrc.js')) || fs_1.default.existsSync(path_1.default.join(cwd, '.eslintrc.cjs'));
}
exports.isCorrectCwd = isCorrectCwd;
//# 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;;;;;;AAE3D,4CAAoB;AACpB,gDAAwB;AAExB,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;AACzG,CAAC;AAFD,oCAEC","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 path from 'path';\n\nexport function isCorrectCwd(cwd: string): boolean {\n return fs.existsSync(path.join(cwd, '.eslintrc.js')) || fs.existsSync(path.join(cwd, '.eslintrc.cjs'));\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,SAa7B;AAED,wBAAgB,SAAS,SA8BxB;AAED,wBAAgB,iBAAiB,SA6BhC"}

View File

@ -0,0 +1,82 @@
"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.printSuppressHelp = exports.printHelp = exports.printPruneHelp = void 0;
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);
}
}
exports.printPruneHelp = printPruneHelp;
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);
}
}
exports.printHelp = printHelp;
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);
}
}
exports.printSuppressHelp = printSuppressHelp;
//# 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;;;AAE3D,+DAAyD;AAEzD,SAAgB,cAAc;IAC5B,MAAM,IAAI,GAAG;;;;;;sNAMuM,CAAC;IAErN,MAAM,OAAO,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAbD,wCAaC;AAED,SAAgB,SAAS;IACvB,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;CAuBd,CAAC;IAEA,MAAM,OAAO,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AA9BD,8BA8BC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;4DAsB6C,CAAC;IAE3D,MAAM,OAAO,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AA7BD,8CA6BC","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() {\n const help = `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 = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n\nexport function printHelp() {\n const help = `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 = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n\nexport function printSuppressHelp() {\n const help = `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 = 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,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 });
exports.wrapWordsToLines = void 0;
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;
}
exports.wrapWordsToLines = wrapWordsToLines;
//# sourceMappingURL=wrap-words-to-lines.js.map

File diff suppressed because one or more lines are too long

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 generatePatchedFileIfDoesntExist(inputFilePath: string, outputFilePath: 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":"AAKA;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CA2QpG"}

View File

@ -0,0 +1,251 @@
"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.generatePatchedFileIfDoesntExist = void 0;
const fs_1 = __importDefault(require("fs"));
/**
* 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 generatePatchedFileIfDoesntExist(inputFilePath, outputFilePath) {
if (fs_1.default.existsSync(outputFilePath)) {
return;
}
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;
}
/**
* Returns index of next public method
* @param {number} fromIndex index of inputFile to search if public method still exists
* @returns {number} -1 if public method does not exist or index of next public method
*/
function getIndexOfNextPublicMethod(fromIndex) {
const rest = inputFile.substring(fromIndex);
const endOfClassIndex = rest.indexOf('\n}');
const markerForStartOfClassMethod = '\n */\n ';
const startOfClassMethodIndex = rest.indexOf(markerForStartOfClassMethod);
if (startOfClassMethodIndex === -1 || startOfClassMethodIndex > endOfClassIndex) {
return -1;
}
let afterMarkerIndex = rest.indexOf(markerForStartOfClassMethod) + markerForStartOfClassMethod.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');
if (isPublicMethod) {
return fromIndex + afterMarkerIndex;
}
return getIndexOfNextPublicMethod(fromIndex + afterMarkerIndex);
}
/**
* @param {number} indexToScanTo
* @returns {string}
*/
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('../../bulk-suppressions-patch');
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 ---
`;
// Match this:
// const ruleContext = Object.freeze(
// Object.assign(Object.create(sharedTraversalContext), {
// id: ruleId,
// options: getRuleOptions(configuredRules[ruleId]),
// report(...args) {
// /*
// * Create a report translator lazily.
//
// Convert to something like this:
//
// const ruleContext = Object.freeze(
// Object.assign(Object.create(sharedTraversalContext), {
// id: ruleId,
// options: getRuleOptions(configuredRules[ruleId]),
// report(...args) {
// if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode, ruleId })) return;
// /*
// * Create a report translator lazily.
//
outputFile += scanUntilMarker('const ruleContext = Object.freeze(');
outputFile += scanUntilMarker('report(...args) {');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode, ruleId })) return;
// --- END MONKEY PATCH ---
`;
// Match this:
// nodeQueue.forEach((traversalInfo) => {
// currentNode = traversalInfo.node;
//
// try {
// if (traversalInfo.isEntering) {
// eventGenerator.enterNode(currentNode);
// } else {
// eventGenerator.leaveNode(currentNode);
// }
// } catch (err) {
// err.currentNode = currentNode;
// throw err;
// }
// });
//
// return lintingProblems;
//
// Convert to this:
// nodeQueue.forEach((traversalInfo) => {
// currentNode = traversalInfo.node;
//
// try {
// if (traversalInfo.isEntering) {
// eventGenerator.enterNode(currentNode);
// } else {
// eventGenerator.leaveNode(currentNode);
// }
// } catch (err) {
// err.currentNode = currentNode;
// throw err;
// }
// });
//
// // --- BEGIN MONKEY PATCH ---
// bulkSuppressionsPatch.onFinish({ filename });
// // --- END MONKEY PATCH ---
//
// return lintingProblems;
outputFile += scanUntilMarker('nodeQueue.forEach(traversalInfo => {');
outputFile += scanUntilMarker('});');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
bulkSuppressionsPatch.onFinish({ filename });
// --- 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 ---
`;
let indexOfNextPublicMethod = getIndexOfNextPublicMethod(inputIndex);
while (indexOfNextPublicMethod !== -1) {
outputFile += scanUntilIndex(indexOfNextPublicMethod);
outputFile += scanUntilNewline();
outputFile += ` // --- BEGIN MONKEY PATCH ---
this._conditionallyReinitialize();
// --- END MONKEY PATCH ---
`;
indexOfNextPublicMethod = getIndexOfNextPublicMethod(inputIndex);
}
outputFile += scanUntilEnd();
fs_1.default.writeFileSync(outputFilePath, outputFile);
}
exports.generatePatchedFileIfDoesntExist = generatePatchedFileIfDoesntExist;
//# 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,24 @@
"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");
if (!_patch_base_1.eslintFolder) {
console.error('@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.');
process.exit(1);
}
if (process.env._RUSHSTACK_ESLINT_BULK_DETECT === 'true') {
(0, path_utils_1.findAndConsoleLogPatchPathCli)(__dirname);
process.exit(0);
}
const pathToLinterJS = (0, path_utils_1.getPathToLinterJS)();
const nameOfGeneratedPatchFile = (0, path_utils_1.getNameOfGeneratedPatchFile)();
const pathToGeneratedPatch = (0, path_utils_1.getPathToGeneratedPatch)(__dirname, nameOfGeneratedPatchFile);
(0, generate_patched_file_1.generatePatchedFileIfDoesntExist)(pathToLinterJS, pathToGeneratedPatch);
const { Linter: LinterPatch } = require(pathToGeneratedPatch);
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,gDAA8C;AAC9C,6CAKsB;AACtB,uEAAuD;AACvD,mEAA2E;AAE3E,IAAI,CAAC,0BAAY,EAAE,CAAC;IAClB,OAAO,CAAC,KAAK,CACX,gGAAgG,CACjG,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,MAAM,EAAE,CAAC;IACzD,IAAA,0CAA6B,EAAC,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,cAAc,GAAG,IAAA,8BAAiB,GAAE,CAAC;AAC3C,MAAM,wBAAwB,GAAG,IAAA,wCAA2B,GAAE,CAAC;AAE/D,MAAM,oBAAoB,GAAG,IAAA,oCAAuB,EAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;AAC1F,IAAA,wDAAgC,EAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;AACvE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE9D,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 } from '../_patch-base';\nimport {\n findAndConsoleLogPatchPathCli,\n getPathToLinterJS,\n getPathToGeneratedPatch,\n getNameOfGeneratedPatchFile\n} from './path-utils';\nimport { patchClass } from './bulk-suppressions-patch';\nimport { generatePatchedFileIfDoesntExist } from './generate-patched-file';\n\nif (!eslintFolder) {\n console.error(\n '@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.'\n );\n process.exit(1);\n}\n\nif (process.env._RUSHSTACK_ESLINT_BULK_DETECT === 'true') {\n findAndConsoleLogPatchPathCli(__dirname);\n process.exit(0);\n}\n\nconst pathToLinterJS = getPathToLinterJS();\nconst nameOfGeneratedPatchFile = getNameOfGeneratedPatchFile();\n\nconst pathToGeneratedPatch = getPathToGeneratedPatch(__dirname, nameOfGeneratedPatchFile);\ngeneratePatchedFileIfDoesntExist(pathToLinterJS, pathToGeneratedPatch);\nconst { Linter: LinterPatch } = require(pathToGeneratedPatch);\n\nconst { Linter } = require(pathToLinterJS);\n\npatchClass(Linter, LinterPatch);\n"]}

View File

@ -0,0 +1,5 @@
export declare function findAndConsoleLogPatchPathCli(patchPath: string): void;
export declare function getPathToLinterJS(): string;
export declare function getPathToGeneratedPatch(patchPath: string, nameOfGeneratedPatchFile: string): string;
export declare function getNameOfGeneratedPatchFile(): 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":"AAOA,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAoBrE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,GAAG,MAAM,CAKnG;AAcD,wBAAgB,2BAA2B,WAI1C"}

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.getNameOfGeneratedPatchFile = exports.getPathToGeneratedPatch = exports.getPathToLinterJS = exports.findAndConsoleLogPatchPathCli = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const _patch_base_1 = require("../_patch-base");
function findAndConsoleLogPatchPathCli(patchPath) {
if (process.env._RUSHSTACK_ESLINT_BULK_DETECT !== 'true') {
return;
}
const startDelimiter = 'RUSHSTACK_ESLINT_BULK_START';
const endDelimiter = 'RUSHSTACK_ESLINT_BULK_END';
const configuration = {
/**
* `@rushtack/eslint`-bulk should report an error if its package.json is older than this number
*/
minCliVersion: '0.0.0',
/**
* `@rushtack/eslint-bulk` will invoke this entry point
*/
cliEntryPoint: path_1.default.resolve(patchPath, '..', 'exports', 'eslint-bulk.js')
};
console.log(startDelimiter + JSON.stringify(configuration) + endDelimiter);
}
exports.findAndConsoleLogPatchPathCli = findAndConsoleLogPatchPathCli;
function getPathToLinterJS() {
if (!_patch_base_1.eslintFolder) {
throw new Error('Cannot find ESLint installation to patch.');
}
return path_1.default.join(_patch_base_1.eslintFolder, 'lib', 'linter', 'linter.js');
}
exports.getPathToLinterJS = getPathToLinterJS;
function getPathToGeneratedPatch(patchPath, nameOfGeneratedPatchFile) {
fs_1.default.mkdirSync(path_1.default.join(patchPath, 'temp', 'patches'), { recursive: true });
const pathToGeneratedPatch = path_1.default.join(patchPath, 'temp', 'patches', nameOfGeneratedPatchFile);
return pathToGeneratedPatch;
}
exports.getPathToGeneratedPatch = getPathToGeneratedPatch;
function getEslintPackageVersion() {
if (!_patch_base_1.eslintFolder) {
throw new Error('Cannot find ESLint installation to patch.');
}
const eslintPackageJsonPath = path_1.default.join(_patch_base_1.eslintFolder, 'package.json');
const eslintPackageJson = fs_1.default.readFileSync(eslintPackageJsonPath).toString();
const eslintPackageObject = JSON.parse(eslintPackageJson);
const eslintPackageVersion = eslintPackageObject.version;
return eslintPackageVersion;
}
function getNameOfGeneratedPatchFile() {
const eslintPackageVersion = getEslintPackageVersion();
const nameOfGeneratedPatchFile = `linter-patch-v${eslintPackageVersion}.js`;
return nameOfGeneratedPatchFile;
}
exports.getNameOfGeneratedPatchFile = getNameOfGeneratedPatchFile;
//# 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,4CAAoB;AACpB,gDAAwB;AACxB,gDAA8C;AAE9C,SAAgB,6BAA6B,CAAC,SAAiB;IAC7D,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,MAAM,EAAE,CAAC;QACzD,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,6BAA6B,CAAC;IACrD,MAAM,YAAY,GAAG,2BAA2B,CAAC;IAEjD,MAAM,aAAa,GAAG;QACpB;;WAEG;QACH,aAAa,EAAE,OAAO;QACtB;;WAEG;QACH,aAAa,EAAE,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,CAAC;KAC1E,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC,CAAC;AAC7E,CAAC;AApBD,sEAoBC;AAED,SAAgB,iBAAiB;IAC/B,IAAI,CAAC,0BAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,cAAI,CAAC,IAAI,CAAC,0BAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC/D,CAAC;AAND,8CAMC;AAED,SAAgB,uBAAuB,CAAC,SAAiB,EAAE,wBAAgC;IACzF,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,MAAM,oBAAoB,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,wBAAwB,CAAC,CAAC;IAE/F,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AALD,0DAKC;AAED,SAAS,uBAAuB;IAC9B,IAAI,CAAC,0BAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,qBAAqB,GAAG,cAAI,CAAC,IAAI,CAAC,0BAAY,EAAE,cAAc,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,YAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC5E,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,OAAO,CAAC;IAEzD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,SAAgB,2BAA2B;IACzC,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IACvD,MAAM,wBAAwB,GAAG,iBAAiB,oBAAoB,KAAK,CAAC;IAC5E,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAJD,kEAIC","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 path from 'path';\nimport { eslintFolder } from '../_patch-base';\n\nexport function findAndConsoleLogPatchPathCli(patchPath: string): void {\n if (process.env._RUSHSTACK_ESLINT_BULK_DETECT !== 'true') {\n return;\n }\n\n const startDelimiter = 'RUSHSTACK_ESLINT_BULK_START';\n const endDelimiter = 'RUSHSTACK_ESLINT_BULK_END';\n\n const configuration = {\n /**\n * `@rushtack/eslint`-bulk should report an error if its package.json is older than this number\n */\n minCliVersion: '0.0.0',\n /**\n * `@rushtack/eslint-bulk` will invoke this entry point\n */\n cliEntryPoint: path.resolve(patchPath, '..', 'exports', 'eslint-bulk.js')\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 path.join(eslintFolder, 'lib', 'linter', 'linter.js');\n}\n\nexport function getPathToGeneratedPatch(patchPath: string, nameOfGeneratedPatchFile: string): string {\n fs.mkdirSync(path.join(patchPath, 'temp', 'patches'), { recursive: true });\n const pathToGeneratedPatch = path.join(patchPath, 'temp', 'patches', nameOfGeneratedPatchFile);\n\n return pathToGeneratedPatch;\n}\n\nfunction getEslintPackageVersion() {\n if (!eslintFolder) {\n throw new Error('Cannot find ESLint installation to patch.');\n }\n const eslintPackageJsonPath = path.join(eslintFolder, 'package.json');\n const eslintPackageJson = fs.readFileSync(eslintPackageJsonPath).toString();\n const eslintPackageObject = JSON.parse(eslintPackageJson);\n const eslintPackageVersion = eslintPackageObject.version;\n\n return eslintPackageVersion;\n}\n\nexport function getNameOfGeneratedPatchFile() {\n const eslintPackageVersion = getEslintPackageVersion();\n const nameOfGeneratedPatchFile = `linter-patch-v${eslintPackageVersion}.js`;\n return nameOfGeneratedPatchFile;\n}\n"]}

View File

@ -0,0 +1 @@
//# 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":""}

View File

@ -0,0 +1,6 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
// "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,OAAO,CAAC,uCAAuC,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\n// \"lib/exports/eslint-bulk\" is the entry point for the @rushstack/eslint-bulk command line front end.\n\nrequire('../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,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 });
// 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;
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

View File

@ -0,0 +1 @@
{"version":3,"file":"modern-module-resolution.js","sourceRoot":"","sources":["../src/modern-module-resolution.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,wEAAwE;AACxE,EAAE;AACF,oHAAoH;AACpH,EAAE;AACF,kEAAkE;AAClE,EAAE;AAEF,+CAKuB;AAEvB,oHAAoH;AACpH,MAAM,qBAAqB,GAA6B,CAAC,EAAE,EAAE,EAAE,CAC7D,CAAC,EAAoC,aAApC,EAAE,uBAAF,EAAE,CAAoC,IAAI,MAAK,uBAAuB,CAAC;AAE1E,IAAI,CAAC,gCAAkB,CAAC,mBAAmB,EAAE,CAAC;IAC5C,gCAAkB,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAC9C,MAAM,kBAAkB,GAAG,gCAAkB,CAAC,SAAS,CAAC,WAAW,CAAC;IAEpE,IAAI,kCAAoB,KAAK,CAAC,EAAE,CAAC;QAC/B,aAAa;QACb,6HAA6H;QAC7H,gCAAkB,CAAC,SAAS,CAAC,WAAW,GAAG,UACzC,IAAY,EACZ,YAAoB,EACpB,YAAoB;YAEpB,MAAM,eAAe,GAAG,4BAAc,CAAC,OAAO,CAAC;YAC/C,IAAI,CAAC;gBACH,4BAAc,CAAC,OAAO,GAAG,UAAU,UAAkB,EAAE,cAAsB;oBAC3E,IAAI,CAAC;wBACH,uDAAuD;wBACvD,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;oBAC9D,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,IAAI,IAAA,qCAAuB,EAAC,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;4BAC3D,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;wBAChE,CAAC;wBACD,MAAM,CAAC,CAAC;oBACV,CAAC;gBACH,CAAC,CAAC;gBACF,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACnD,CAAC;oBAAS,CAAC;gBACT,4BAAc,CAAC,OAAO,GAAG,eAAe,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,oBAAoB;QACpB,qHAAqH;QACrH,gCAAkB,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,IAAY,EAAE,GAA4B;YAC7F,MAAM,eAAe,GAAG,4BAAc,CAAC,OAAO,CAAC;YAC/C,IAAI,CAAC;gBACH,4BAAc,CAAC,OAAO,GAAG,UAAU,UAAkB,EAAE,cAAsB;oBAC3E,IAAI,CAAC;wBACH,uDAAuD;wBACvD,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;oBAC9D,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,IAAI,IAAA,qCAAuB,EAAC,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;4BAC3D,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;wBAChE,CAAC;wBACD,MAAM,CAAC,CAAC;oBACV,CAAC;gBACH,CAAC,CAAC;gBACF,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACnD,CAAC;oBAAS,CAAC;gBACT,4BAAc,CAAC,OAAO,GAAG,eAAe,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC;IACJ,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\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\n//\n// To correct how ESLint searches for plugin packages, add this line to the top of your project's .eslintrc.js file:\n//\n// require(\"@rushstack/eslint-patch/modern-module-resolution\");\n//\n\nimport {\n ConfigArrayFactory,\n ModuleResolver,\n isModuleResolutionError,\n ESLINT_MAJOR_VERSION\n} from './_patch-base';\n\n// error: \"The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''\"\nconst isInvalidImporterPath: (ex: unknown) => boolean = (ex) =>\n (ex as { code: unknown } | undefined)?.code === 'ERR_INVALID_ARG_VALUE';\n\nif (!ConfigArrayFactory.__loadPluginPatched) {\n ConfigArrayFactory.__loadPluginPatched = true;\n const originalLoadPlugin = ConfigArrayFactory.prototype._loadPlugin;\n\n if (ESLINT_MAJOR_VERSION === 6) {\n // ESLint 6.x\n // https://github.com/eslint/eslint/blob/9738f8cc864d769988ccf42bb70f524444df1349/lib/cli-engine/config-array-factory.js#L915\n ConfigArrayFactory.prototype._loadPlugin = function (\n name: string,\n importerPath: string,\n importerName: string\n ) {\n const originalResolve = ModuleResolver.resolve;\n try {\n ModuleResolver.resolve = function (moduleName: string, relativeToPath: string) {\n try {\n // resolve using importerPath instead of relativeToPath\n return originalResolve.call(this, moduleName, importerPath);\n } catch (e) {\n if (isModuleResolutionError(e) || isInvalidImporterPath(e)) {\n return originalResolve.call(this, moduleName, relativeToPath);\n }\n throw e;\n }\n };\n return originalLoadPlugin.apply(this, arguments);\n } finally {\n ModuleResolver.resolve = originalResolve;\n }\n };\n } else {\n // ESLint 7.x || 8.x\n // https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L1023\n ConfigArrayFactory.prototype._loadPlugin = function (name: string, ctx: Record<string, unknown>) {\n const originalResolve = ModuleResolver.resolve;\n try {\n ModuleResolver.resolve = function (moduleName: string, relativeToPath: string) {\n try {\n // resolve using ctx.filePath instead of relativeToPath\n return originalResolve.call(this, moduleName, ctx.filePath);\n } catch (e) {\n if (isModuleResolutionError(e) || isInvalidImporterPath(e)) {\n return originalResolve.call(this, moduleName, relativeToPath);\n }\n throw e;\n }\n };\n return originalLoadPlugin.apply(this, arguments);\n } finally {\n ModuleResolver.resolve = originalResolve;\n }\n };\n }\n}\n"]}

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');

39
VApp/node_modules/@rushstack/eslint-patch/package.json generated vendored Normal file
View File

@ -0,0 +1,39 @@
{
"name": "@rushstack/eslint-patch",
"version": "1.7.2",
"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.64.0",
"@rushstack/heft-node-rig": "2.4.0",
"@types/node": "18.17.15",
"typescript": "~5.3.3",
"@typescript-eslint/types": "~5.59.2"
},
"scripts": {
"build": "heft build --clean",
"_phase:build": "heft run --only build -- --clean"
}
}