Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
byCodemod
Netlify/Replace Feature Flag
Last update
Jul 24, 2024
This codemod replaces feature flags with a static value provided by the user.
Codemod replaces useFlag
hook calls.
The codemod accepts the following arguments:
key
: The key of the feature flag to be replaced.value
: The value to replace the feature flag with.type
: The type to which the provided value should be cast.
Example
Before
const theValue = useFlag("the-gate").value;if (theValue) {// Simple Case is trueconsole.log('theValue is truthy')}if (theValue === 3) {console.log('value var === 3')}const x = theValue ? 1 : 0
After
// Simple Case is trueconsole.log('theValue is truthy')const x = 1;
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community