openfeature-remove-stale-flag
Remove a stale OpenFeature flag evaluation (Node/web/React) and simplify leftover control flow
Removes a stale OpenFeature feature-flag evaluation and simplifies leftover control flow once the flag has a permanent value.
## Coverage
JS/TS OpenFeature evaluation call sites:
| Surface | Matched shapes |
| --- | --- |
| Node server / web SDK | `*.getBooleanValue('flagKey' \| FlagKeys.X \| constKey, …)` (any receiver; optional `await`) |
| React SDK | `useBooleanFlagValue(...)`, `useFlag(...).value` |
| Codegen / hand wrappers | `useFlagXxx()` when the resolved function body calls `useFlag(<flagKey>, …)` |
## Params
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| `flagKey` | string | `sample_flag_key` | Literal flag key to remove (also matched via resolved consts) |
| `value` | boolean | `true` | Permanent resolved value (`true` = keep the enabled path, `false` = keep the disabled path) |
### Example
Dry-run against the current directory (uses defaults: `sample_flag_key` / `true`):
```bash
npx codemod run openfeature-remove-stale-flag -t . \
--dry-run \
--report
```
Override for a flag that stayed off:
```bash
npx codemod run openfeature-remove-stale-flag -t . \
--param flagKey=sample_flag_key \
--param value=false
```
From a local checkout of this package (before publish), point at the workflow file:
```bash
npx codemod workflow run \
-w path/to/openfeature-remove-stale-flag/workflow.yaml \
-t /path/to/your/app \
--dry-run \
--report
```
## Metric: `openfeature_stale_flag_removed`
Emitted once per rewritten evaluation site.
| field | description |
| --- | --- |
| `flag_key` | Matched literal key |
| `value` | `"true"` or `"false"` |
| `pattern` | Site shape (`await_binding_if`, `inline_await_if`, `ternary`, `logical_and`, `logical_or`, `negated_if`, `with_context`, `simple_replace`, `react_hook`, `generated_hook`, …) |
| `outcome` | `rewritten` or `skipped_escaped` |
## Safety
- Only flag keys that resolve to the `flagKey` param (literals or one-hop consts / `FlagKeys.X`)
- Skips sites where the evaluation result escapes (exports, object properties, callback args)
- Does not rewrite bodies of generated `useFlag*` definitions (call sites only)
- Idempotent