source: frontend/node_modules/@rushstack/eslint-patch/lib-commonjs/eslint-bulk-suppressions/cli/prune.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.7 KB
Line 
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.
4var __importDefault = (this && this.__importDefault) || function (mod) {
5 return (mod && mod.__esModule) ? mod : { "default": mod };
6};
7Object.defineProperty(exports, "__esModule", { value: true });
8exports.pruneAsync = pruneAsync;
9const node_fs_1 = __importDefault(require("node:fs"));
10const print_help_1 = require("./utils/print-help");
11const runEslint_1 = require("./runEslint");
12const constants_1 = require("../constants");
13const bulk_suppressions_file_1 = require("../bulk-suppressions-file");
14async function pruneAsync() {
15 const args = process.argv.slice(3);
16 if (args.includes('--help') || args.includes('-h')) {
17 (0, print_help_1.printPruneHelp)();
18 process.exit(0);
19 }
20 if (args.length > 0) {
21 throw new Error(`@rushstack/eslint-bulk: Unknown arguments: ${args.join(' ')}`);
22 }
23 const normalizedCwd = process.cwd().replace(/\\/g, '/');
24 const allFiles = await getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd);
25 if (allFiles.length > 0) {
26 process.env[constants_1.ESLINT_BULK_PRUNE_ENV_VAR_NAME] = '1';
27 console.log(`Pruning suppressions for ${allFiles.length} files...`);
28 await (0, runEslint_1.runEslintAsync)(allFiles, 'prune');
29 }
30 else {
31 console.log('No files with existing suppressions found.');
32 (0, bulk_suppressions_file_1.deleteBulkSuppressionsFileInEslintConfigFolder)(normalizedCwd);
33 }
34}
35async function getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd) {
36 const { jsonObject: bulkSuppressionsConfigJson } = (0, bulk_suppressions_file_1.getSuppressionsConfigForEslintConfigFolderPath)(normalizedCwd);
37 const allFiles = new Set();
38 for (const { file: filePath } of bulkSuppressionsConfigJson.suppressions) {
39 allFiles.add(filePath);
40 }
41 const allFilesArray = Array.from(allFiles);
42 const allExistingFiles = [];
43 // TODO: limit parallelism here with something similar to `Async.forEachAsync` from `node-core-library`.
44 await Promise.all(allFilesArray.map(async (filePath) => {
45 try {
46 await node_fs_1.default.promises.access(filePath, node_fs_1.default.constants.F_OK);
47 allExistingFiles.push(filePath);
48 }
49 catch (_a) {
50 // Doesn't exist - ignore
51 }
52 }));
53 console.log(`Found ${allExistingFiles.length} files with existing suppressions.`);
54 const deletedCount = allFilesArray.length - allExistingFiles.length;
55 if (deletedCount > 0) {
56 console.log(`${deletedCount} files with suppressions were deleted.`);
57 }
58 return allExistingFiles;
59}
60//# sourceMappingURL=prune.js.map
Note: See TracBrowser for help on using the repository browser.