From 2ccf46a56abd5e5c03c7e7bb5ece58c2f0965001 Mon Sep 17 00:00:00 2001 From: "taotie-bot[bot]" <120676786+taotie-bot[bot]@users.noreply.github.com> Date: Sun, 6 Aug 2023 13:49:45 +0000 Subject: [PATCH] chore(flags): remove flag feature-flag --- src/example-2-rebase.ts | 100 ++++++---------------------------- src/index.ts | 8 --- src/remove-simple-if-flags.ts | 100 ++++++---------------------------- 3 files changed, 32 insertions(+), 176 deletions(-) diff --git a/src/example-2-rebase.ts b/src/example-2-rebase.ts index 61c1b02..e474278 100644 --- a/src/example-2-rebase.ts +++ b/src/example-2-rebase.ts @@ -1,99 +1,31 @@ -import { featureFlag, f1, f2 } from './common' - -const context = { - featureFlag: true, - fflag: { - featureFlag: true - }, - data: { - fflag: { - featureFlag: true - } - } -} +import { f1, f2 } from './common' // If feature flag is true (f1) -if (featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag is false (f2) -if (!featureFlag) { - f1() -} else { - f2() -} - +f2() // If conditional doesn't have a block wrapper (f1) -if (featureFlag) f1() -else { - f2() -} +f1() // If else conditional doesn't have a block wrapper (f2) -if (!featureFlag) f1() -else f2() +f2() // If there are multiple statements inside the block (f1, f2, f3) -if (featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f1() +f2() +f1() // If there are multiple statements inside the block (inverse) (f2, f1) -if (!featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f2() +f1() // If feature flag within context (f1) -if (context.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f1) -if (context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within context (inverse) (f2) -if (!context.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (inverse) (f2) -if (!context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (f1) -if (context.data.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f2) -if (!context.data.fflag.featureFlag) { - f1() -} else { - f2() -} +f2() diff --git a/src/index.ts b/src/index.ts index 00b03e2..8b13789 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1 @@ -const context = { - featureFlag: false -} -if (context.featureFlag) { - console.log('Show the exciting new feature') -} else { - console.log('Show the old feature') -} diff --git a/src/remove-simple-if-flags.ts b/src/remove-simple-if-flags.ts index 61c1b02..e474278 100644 --- a/src/remove-simple-if-flags.ts +++ b/src/remove-simple-if-flags.ts @@ -1,99 +1,31 @@ -import { featureFlag, f1, f2 } from './common' - -const context = { - featureFlag: true, - fflag: { - featureFlag: true - }, - data: { - fflag: { - featureFlag: true - } - } -} +import { f1, f2 } from './common' // If feature flag is true (f1) -if (featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag is false (f2) -if (!featureFlag) { - f1() -} else { - f2() -} - +f2() // If conditional doesn't have a block wrapper (f1) -if (featureFlag) f1() -else { - f2() -} +f1() // If else conditional doesn't have a block wrapper (f2) -if (!featureFlag) f1() -else f2() +f2() // If there are multiple statements inside the block (f1, f2, f3) -if (featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f1() +f2() +f1() // If there are multiple statements inside the block (inverse) (f2, f1) -if (!featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f2() +f1() // If feature flag within context (f1) -if (context.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f1) -if (context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within context (inverse) (f2) -if (!context.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (inverse) (f2) -if (!context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (f1) -if (context.data.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f2) -if (!context.data.fflag.featureFlag) { - f1() -} else { - f2() -} +f2()