Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 16 additions & 84 deletions src/example-2-rebase.ts
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 0 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
const context = {
featureFlag: false
}

if (context.featureFlag) {
console.log('Show the exciting new feature')
} else {
console.log('Show the old feature')
}
100 changes: 16 additions & 84 deletions src/remove-simple-if-flags.ts
Original file line number Diff line number Diff line change
@@ -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()