angusjf

Jake Cleaning up the desk in Adventure Time

Expiring Feature Flags

As a developer who does a lot of tiny content changes, I think feature flags are a great idea.

As a quick example, imagine you need to add some copy to your website:

<p>We are regulated by the Financial Conduct Authority [FRN: 580101]</p>

BUT WAIT! You haven't actually got your FCA approval yet, so you can't publish this or you'll get in massive trouble.

Thankfully you've set up a feature flag service:

const showFcaNumber = useFlag("show-fca-number");

if (showFcaNumber) {
  return (
    <p>We are regulated by the Financial Conduct Authority [FRN: 580101]</p>
  );
} else {
  return <p>We are not regulated yet...</p>;
}

Now we have our changes ready to go as soon as they're needed.

However, in a few months this flag will be enabled forever and that 'else branch' will become dead code. How will we remember to remove it?

// TODO: Remove flag and else branch when we get regulated

We all know that comment is never getting removed... It's common knowledge that most TODO comments are never followed up on. Are we doomed to forever pile on more and more bloat into our codebase?

The solution is expiring-todo-comments, an ingenious eslint rule to stop your CI passing when you leave TODOs in too long.

// TODO [2023-11-28]: Remove flag and else branch when we get regulated

Problem solved!