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,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,IAAA,0BAAc,EAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAEnD,IAAI,UAAU,CAAC,GAAG,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,yEAAyE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAC3G,CAAC;SAAM,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,GAAG,CACT,yDAAyD,UAAU,CAAC,KAAK,gBAAgB,UAAU,CAAC,KAAK,EAAE,CAC5G,CAAC;IACJ,CAAC;AACH,CAAC;AAvED,sCAuEC","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 { printSuppressHelp } from './utils/print-help';\nimport { runEslintAsync } from './runEslint';\nimport { ESLINT_BULK_SUPPRESS_ENV_VAR_NAME } from '../constants';\n\ninterface IParsedArgs {\n rules: string[];\n all: boolean;\n files: string[];\n}\n\nexport async function suppressAsync(): Promise<void> {\n const args: string[] = process.argv.slice(3);\n\n if (args.includes('--help') || args.includes('-h')) {\n printSuppressHelp();\n process.exit(0);\n }\n\n // Use reduce to create an object with all the parsed arguments\n const parsedArgs: IParsedArgs = args.reduce<{\n rules: string[];\n all: boolean;\n files: string[];\n }>(\n (acc, arg, index, arr) => {\n if (arg === '--rule') {\n // continue because next arg should be the rule\n } else if (index > 0 && arr[index - 1] === '--rule' && arr[index + 1]) {\n acc.rules.push(arg);\n } else if (arg === '--all') {\n acc.all = true;\n } else if (arg.startsWith('--')) {\n throw new Error(`@rushstack/eslint-bulk: Unknown option: ${arg}`);\n } else {\n acc.files.push(arg);\n }\n return acc;\n },\n { rules: [], all: false, files: [] }\n );\n\n if (parsedArgs.files.length === 0) {\n throw new Error(\n '@rushstack/eslint-bulk: Files argument is required. Use glob patterns to specify files or use ' +\n '`.` to suppress all files for the specified rules.'\n );\n }\n\n if (parsedArgs.rules.length === 0 && !parsedArgs.all) {\n throw new Error(\n '@rushstack/eslint-bulk: Please specify at least one rule to suppress. Use --all to suppress all rules.'\n );\n }\n\n // Find the index of the last argument that starts with '--'\n const lastOptionIndex: number = args\n .map((arg, i) => (arg.startsWith('--') ? i : -1))\n .reduce((lastIndex, currentIndex) => Math.max(lastIndex, currentIndex), -1);\n\n // Check if options come before files\n if (parsedArgs.files.some((file) => args.indexOf(file) < lastOptionIndex)) {\n throw new Error(\n '@rushstack/eslint-bulk: Unable to parse command line arguments. All options should come before files argument.'\n );\n }\n\n if (parsedArgs.all) {\n process.env[ESLINT_BULK_SUPPRESS_ENV_VAR_NAME] = '*';\n } else if (parsedArgs.rules.length > 0) {\n process.env[ESLINT_BULK_SUPPRESS_ENV_VAR_NAME] = parsedArgs.rules.join(',');\n }\n\n await runEslintAsync(parsedArgs.files, 'suppress');\n\n if (parsedArgs.all) {\n console.log(`@rushstack/eslint-bulk: Successfully suppressed all rules for file(s) ${parsedArgs.files}`);\n } else if (parsedArgs.rules.length > 0) {\n console.log(\n `@rushstack/eslint-bulk: Successfully suppressed rules ${parsedArgs.rules} for file(s) ${parsedArgs.files}`\n );\n }\n}\n"]} |