From adff2fae16a953c89031c68afd60b39f21b3e1d8 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 19 Mar 2024 14:37:08 -0700 Subject: [PATCH] Support '1' in addition to 'true' in env var boolean values. --- .../eslint-bulk-suppressions/bulk-suppressions-patch.ts | 2 +- .../eslint-patch/src/eslint-bulk-suppressions/cli/prune.ts | 2 +- .../src/eslint-bulk-suppressions/generate-patched-file.ts | 7 +++---- eslint/eslint-patch/src/eslint-bulk-suppressions/index.ts | 3 ++- .../src/eslint-bulk-suppressions/path-utils.ts | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/eslint/eslint-patch/src/eslint-bulk-suppressions/bulk-suppressions-patch.ts b/eslint/eslint-patch/src/eslint-bulk-suppressions/bulk-suppressions-patch.ts index 37d60d1c4aa..a242337a960 100644 --- a/eslint/eslint-patch/src/eslint-bulk-suppressions/bulk-suppressions-patch.ts +++ b/eslint/eslint-patch/src/eslint-bulk-suppressions/bulk-suppressions-patch.ts @@ -258,7 +258,7 @@ export function shouldBulkSuppress(params: { }; } - return process.env[ESLINT_BULK_PRUNE_ENV_VAR_NAME] !== 'true' && currentNodeIsSuppressed; + return process.env[ESLINT_BULK_PRUNE_ENV_VAR_NAME] !== '1' && currentNodeIsSuppressed; } export function prune(): void { diff --git a/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/prune.ts b/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/prune.ts index 511053695f5..8f0a538e1f2 100755 --- a/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/prune.ts +++ b/eslint/eslint-patch/src/eslint-bulk-suppressions/cli/prune.ts @@ -17,7 +17,7 @@ export async function pruneAsync(): Promise { throw new Error(`@rushstack/eslint-bulk: Unknown arguments: ${args.join(' ')}`); } - process.env[ESLINT_BULK_PRUNE_ENV_VAR_NAME] = 'true'; + process.env[ESLINT_BULK_PRUNE_ENV_VAR_NAME] = '1'; await runEslintAsync(['.'], 'prune'); } diff --git a/eslint/eslint-patch/src/eslint-bulk-suppressions/generate-patched-file.ts b/eslint/eslint-patch/src/eslint-bulk-suppressions/generate-patched-file.ts index 17aae8f23b8..fdb97d28afa 100644 --- a/eslint/eslint-patch/src/eslint-bulk-suppressions/generate-patched-file.ts +++ b/eslint/eslint-patch/src/eslint-bulk-suppressions/generate-patched-file.ts @@ -16,10 +16,9 @@ export function generatePatchedLinterJsFileIfDoesNotExist( inputFilePath: string, outputFilePath: string ): void { - if ( - process.env[ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME] !== 'true' && - fs.existsSync(outputFilePath) - ) { + const generateEnvVarValue: string | undefined = + process.env[ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME]; + if (generateEnvVarValue !== 'true' && generateEnvVarValue !== '1' && fs.existsSync(outputFilePath)) { return; } diff --git a/eslint/eslint-patch/src/eslint-bulk-suppressions/index.ts b/eslint/eslint-patch/src/eslint-bulk-suppressions/index.ts index c3071b4ded3..2297af04063 100644 --- a/eslint/eslint-patch/src/eslint-bulk-suppressions/index.ts +++ b/eslint/eslint-patch/src/eslint-bulk-suppressions/index.ts @@ -15,7 +15,8 @@ if (!eslintFolder) { process.exit(1); } -if (process.env[ESLINT_BULK_DETECT_ENV_VAR_NAME] === 'true') { +const eslintBulkDetectEnvVarValue: string | undefined = process.env[ESLINT_BULK_DETECT_ENV_VAR_NAME]; +if (eslintBulkDetectEnvVarValue === 'true' || eslintBulkDetectEnvVarValue === '1') { findAndConsoleLogPatchPathCli(); process.exit(0); } diff --git a/eslint/eslint-patch/src/eslint-bulk-suppressions/path-utils.ts b/eslint/eslint-patch/src/eslint-bulk-suppressions/path-utils.ts index 521d7b03aa0..8a79c5e6eb2 100644 --- a/eslint/eslint-patch/src/eslint-bulk-suppressions/path-utils.ts +++ b/eslint/eslint-patch/src/eslint-bulk-suppressions/path-utils.ts @@ -15,7 +15,8 @@ interface IConfiguration { const CURRENT_PACKAGE_VERSION: string = currentPackageJson.version; export function findAndConsoleLogPatchPathCli(): void { - if (process.env[ESLINT_BULK_DETECT_ENV_VAR_NAME] !== 'true') { + const eslintBulkDetectEnvVarValue: string | undefined = process.env[ESLINT_BULK_DETECT_ENV_VAR_NAME]; + if (eslintBulkDetectEnvVarValue !== 'true' && eslintBulkDetectEnvVarValue !== '1') { return; }