Registry
C

openFeature/replace-feature-flag

No description available

Codemod19 executions

  • Legacy
  • openFeature
  • feature-flag
Connect a repo
npx codemod openFeature/replace-feature-flag

This codemod replaces openFeature compatible feature flags with a static value provided by the user.

Codemod replaces following SDK calls: getBooleanValue, getStringValue, getNumberValue, getObjectValue.

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.

Example

Before

ts
const theValue = getBooleanValue("the-key", true).value;

console.log(getBooleanValue("the-key", false));

if (theValue === true) {
  const someVar = useGate("other-gate1");
  const templateVar = `Hello, ${someVar}`;
  const concatVar = "Goodbye, " + someVar;
}

if (theValue) {
  console.log("theValue is truthy");
}

if (theValue === 3) {
  console.log("value var === 3");
}

const x = theValue ? 1 : 0;

if (getBooleanValue("the-key", true).value === true) {
  console.log("obj.value === true");
}

if (getBooleanValue("the-key", true).value) {
  console.log("obj.value is truthy");
}

console.log(getBooleanValue("the-key", true).value);

After

ts
console.log(true);

const someVar = useGate("other-gate1");
const templateVar = `Hello, ${someVar}`;
const concatVar = "Goodbye, " + someVar;

console.log("theValue is truthy");

const x = 1;

console.log("obj.value === true");
console.log("obj.value is truthy");

console.log(true);

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.