index.js 1.6 KB

123456789101112131415161718192021222324252627
  1. "use strict";
  2. // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
  3. // See LICENSE in the project root for license information.
  4. Object.defineProperty(exports, "__esModule", { value: true });
  5. const _patch_base_1 = require("../_patch-base");
  6. const path_utils_1 = require("./path-utils");
  7. const bulk_suppressions_patch_1 = require("./bulk-suppressions-patch");
  8. const generate_patched_file_1 = require("./generate-patched-file");
  9. const constants_1 = require("./constants");
  10. if (!_patch_base_1.eslintFolder) {
  11. console.error('@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.');
  12. process.exit(1);
  13. }
  14. const eslintBulkDetectEnvVarValue = process.env[constants_1.ESLINT_BULK_DETECT_ENV_VAR_NAME];
  15. if (eslintBulkDetectEnvVarValue === 'true' || eslintBulkDetectEnvVarValue === '1') {
  16. (0, path_utils_1.findAndConsoleLogPatchPathCli)();
  17. process.exit(0);
  18. }
  19. const pathToLinterJS = (0, path_utils_1.getPathToLinterJS)();
  20. process.env[constants_1.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME] = require.resolve('./bulk-suppressions-patch');
  21. const pathToGeneratedPatch = (0, path_utils_1.ensurePathToGeneratedPatch)();
  22. (0, generate_patched_file_1.generatePatchedLinterJsFileIfDoesNotExist)(pathToLinterJS, pathToGeneratedPatch, _patch_base_1.eslintPackageVersion);
  23. const { Linter: LinterPatch } = require(pathToGeneratedPatch);
  24. LinterPatch.prototype.verify = (0, bulk_suppressions_patch_1.extendVerifyFunction)(LinterPatch.prototype.verify);
  25. const { Linter } = require(pathToLinterJS);
  26. (0, bulk_suppressions_patch_1.patchClass)(Linter, LinterPatch);
  27. //# sourceMappingURL=index.js.map