Skip to main content

Expiring @todo conditions for lint disables

A @todo reason can carry a bracketed condition that expires it, so a lint disable doesn't outlive the reason it was added for. When a condition is met, the directive is reported as expired and the run fails until someone looks at it again. The conditions are heavily inspired by unicorn's expiring-todo-comments rule. That rule expires TODO comments; these expire the reason for an eslint-disable or stylelint-disable directive, so the suppression itself comes up for review.

Syntax​

/**
* @todo [2030-01-01, react@^19] Legacy API returns `any`; type it once the SDK is upgraded.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const response: any = await legacyCall();
  • The bracket follows the first @todo in the comment, with spaces or tabs allowed between them. It must fit on one line: a [ with no ] before the end of that line reports one invalidCondition ("condition list must fit on one line").
  • Tokens are separated by commas and trimmed.
  • Prose must still follow the bracket. @todo [2030-01-01] on its own has no reason and is reported as missingReason ("has a @todo without a reason").

Condition kinds​

TokenKindMet (expired) when
2030-01-01datetoday (UTC) is after that date
<2.0.0versionthe package's own version satisfies the range
engine:node@>=20enginethe lowest version engines.node allows satisfies the range
+left-padaddedleft-pad is in dependencies or devDependencies
-left-padremovedleft-pad is in neither
react@^19dependencythe lowest version the declared react range allows satisfies ^19
  • A version token is any semver range. An engine can be any name in engines, e.g. engine:npm@>=10.
  • A dependency is looked up in dependencies, then devDependencies.
  • "Lowest version" is the lowest version a declared range allows: ^18.2.0 counts as 18.2.0, and ^22.22.2 || ^24.15.0 as 22.22.2.
  • Ranges are checked with prereleases included.
  • A date on the day itself is still unmet. A bracket holds at most one date and at most one own-version range; repeats are invalid.

Invalid conditions​

A condition that cannot be checked is reported as invalidCondition, with the reason after the colon:

src/app.ts:12:1 eslint-disable-next-line has an invalid @todo condition [react@^19]: react is not declared in package.json
CaseDetail
an empty token, such as [2030-01-01,]empty condition
a date that is not a real calendar day, such as 2030-02-30not a real calendar date
a second date in one bracketonly one date condition is allowed
a second own-version range in one bracketonly one version condition is allowed
a range that matches every version, such as *, x or >=0.0.0"<range>" matches every version
a token that is not a semver range"<token>" is not a valid semver range
a dependency that is not declared<name> is not declared in package.json
a declared dependency range semver cannot read, such as workspace:*, file:, git URLs or npm: aliases<name> range "<declared>" is not a semver range
an engine that is not declaredno engines.<name> in package.json
a declared engine range semver cannot readengines.<name> range "<declared>" is not a semver range
an own version that is missing or not valid semverno version in package.json
a condition that needs package.json when none is foundno package.json found (needed for the <kind> condition)

<kind> is one of version, engine, added, removed or dependency. Date conditions never need package.json.

Missing date​

missingDate is off by default. It reports a @todo with no date condition. A date that fails the calendar check does not count, so 2030-02-30 raises invalidCondition and, with missingDate on, missingDate as well.

The package.json lookup​

The version, engine, added, removed and dependency kinds read a package.json:

  • The nearest package.json is used. The lookup walks up from the directory of the file holding the directive, to the filesystem root, and reads the first one it finds.
  • The walk can leave the project. A file in a directory with no package.json reads the nearest ancestor's, which may sit outside the project.
  • Each directory is read at most once per run, and only when a condition needs it.
  • Unparsable JSON, or a top level that is not an object, fails the run with invalid package.json: <absolute path> and exit 2. It fails only when a condition reaches that file. Exit codes are described in Usage.

A project at version 0.0.0, the placeholder semantic-release projects keep, compares its own-version conditions against 0.0.0. >=1.0.0 is never met there. A range that includes 0.0.0, such as <1.0.0, is met from the start.