Skip to content

Commit 63d283f

Browse files
committed
add FF lint checks
1 parent 6edb1ae commit 63d283f

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

.github/workflows/test-build.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,33 @@ jobs:
4141
- name: Validate feature flags
4242
run: |
4343
FILE="apps/sim/lib/core/config/feature-flags.ts"
44-
echo "Checking for hardcoded boolean feature flags in $FILE..."
44+
ERRORS=""
4545
46-
# Find any "export const isXxx = true" or "export const isXxx = false" patterns
47-
# This catches accidental local testing values being committed
48-
if grep -E "export const is[A-Za-z]+\s*=\s*(true|false)\s*;?\s*$" "$FILE"; then
49-
echo ""
50-
echo "❌ ERROR: Feature flags must not be hardcoded to boolean literals!"
51-
echo "Feature flags should derive their values from environment variables."
52-
echo ""
53-
echo "Example of what NOT to do:"
54-
echo " export const isHosted = true"
46+
echo "Checking for hardcoded boolean feature flags..."
47+
48+
# Use perl for multiline matching to catch both:
49+
# export const isHosted = true
50+
# export const isHosted =
51+
# true
52+
HARDCODED=$(perl -0777 -ne 'while (/export const (is[A-Za-z]+)\s*=\s*\n?\s*(true|false)\b/g) { print " $1 = $2\n" }' "$FILE")
53+
54+
if [ -n "$HARDCODED" ]; then
55+
ERRORS="${ERRORS}\n❌ Feature flags must not be hardcoded to boolean literals!\n\nFound hardcoded flags:\n${HARDCODED}\n\nFeature flags should derive their values from environment variables.\n"
56+
fi
57+
58+
echo "Checking feature flag naming conventions..."
59+
60+
# Check that all export const (except functions) start with 'is'
61+
# This finds exports like "export const someFlag" that don't start with "is" or "get"
62+
BAD_NAMES=$(grep -E "^export const [a-z]" "$FILE" | grep -vE "^export const (is|get)" | sed 's/export const \([a-zA-Z]*\).*/ \1/')
63+
64+
if [ -n "$BAD_NAMES" ]; then
65+
ERRORS="${ERRORS}\n❌ Feature flags must use 'is' prefix for boolean flags!\n\nFound incorrectly named flags:\n${BAD_NAMES}\n\nExample: 'hostedMode' should be 'isHostedMode'\n"
66+
fi
67+
68+
if [ -n "$ERRORS" ]; then
5569
echo ""
56-
echo "Example of correct implementation:"
57-
echo " export const isHosted = getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai'"
70+
echo -e "$ERRORS"
5871
exit 1
5972
fi
6073

0 commit comments

Comments
 (0)