Skip to content

Commit 689040d

Browse files
chore(flags): remove flag test-flag
1 parent 372bc1b commit 689040d

File tree

2 files changed

+19
-87
lines changed

2 files changed

+19
-87
lines changed

src/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Some typescript symbols
22
export const featureFlag = 'featureFlag'
33

4-
export function f1(): string {
4+
export function f1() {
55
return 'f1'
66
}
77

8-
export function f2(): string {
8+
export function f2() {
99
return 'f2'
1010
}
1111

12-
export function f3(): string {
12+
export function f3() {
1313
return 'f2'
1414
}

src/remove-simple-if-flags.ts

Lines changed: 16 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,31 @@
1-
import { featureFlag, f1, f2 } from './common'
2-
3-
const context = {
4-
featureFlag: true,
5-
fflag: {
6-
featureFlag: true
7-
},
8-
data: {
9-
fflag: {
10-
featureFlag: true
11-
}
12-
}
13-
}
1+
import { f1, f2 } from './common'
142

153
// If feature flag is true (f1)
16-
if (featureFlag) {
17-
f1()
18-
} else {
19-
f2()
20-
}
21-
4+
f1()
225
// If feature flag is false (f2)
23-
if (!featureFlag) {
24-
f1()
25-
} else {
26-
f2()
27-
}
28-
6+
f2()
297
// If conditional doesn't have a block wrapper (f1)
30-
if (featureFlag) f1()
31-
else {
32-
f2()
33-
}
8+
f1()
349

3510
// If else conditional doesn't have a block wrapper (f2)
36-
if (!featureFlag) f1()
37-
else f2()
11+
f2()
3812

3913
// If there are multiple statements inside the block (f1, f2, f3)
40-
if (featureFlag) {
41-
f1()
42-
f2()
43-
f1()
44-
} else {
45-
f2()
46-
f1()
47-
}
48-
14+
f1()
15+
f2()
16+
f1()
4917
// If there are multiple statements inside the block (inverse) (f2, f1)
50-
if (!featureFlag) {
51-
f1()
52-
f2()
53-
f1()
54-
} else {
55-
f2()
56-
f1()
57-
}
58-
18+
f2()
19+
f1()
5920
// If feature flag within context (f1)
60-
if (context.featureFlag) {
61-
f1()
62-
} else {
63-
f2()
64-
}
65-
21+
f1()
6622
// If feature flag within multiple context (f1)
67-
if (context.fflag.featureFlag) {
68-
f1()
69-
} else {
70-
f2()
71-
}
72-
23+
f1()
7324
// If feature flag within context (inverse) (f2)
74-
if (!context.featureFlag) {
75-
f1()
76-
} else {
77-
f2()
78-
}
79-
25+
f2()
8026
// If feature flag within multiple context (inverse) (f2)
81-
if (!context.fflag.featureFlag) {
82-
f1()
83-
} else {
84-
f2()
85-
}
86-
27+
f2()
8728
// If feature flag within multiple context (f1)
88-
if (context.data.fflag.featureFlag) {
89-
f1()
90-
} else {
91-
f2()
92-
}
93-
29+
f1()
9430
// If feature flag within multiple context (f2)
95-
if (!context.data.fflag.featureFlag) {
96-
f1()
97-
} else {
98-
f2()
99-
}
31+
f2()

0 commit comments

Comments
 (0)