fleetlint Policy for a fleet of repositories
v0.7
Getting started

deps/locked-install/node

Installs use the lockfile strictly

Implements deps/locked-install for node.

Severitywarning
Tiers1, 2
Stacksnode
Scopeeach
Kindexpr
Sourcelibrary v0.4.0
Selected byfleetlint-recommended@v0.4.0

Requirement

A recipe or CI step installs with the lockfile enforced: npm ci, pnpm install --frozen-lockfile, yarn install --immutable (or --frozen-lockfile), bun install --frozen-lockfile or bun ci; a plain pnpm install, or yarn install with Yarn Berry (.yarnrc.yml), counts in a CI step, where both freeze the lockfile by default. No recipe or CI step runs a bare npm install or passes --no-frozen-lockfile/--no-immutable.

Why

An install that quietly re-resolves builds and tests something other than what the lockfile in git says, and the drift shows up only in production.

Check

(taskrunner.recipes.filter(t, !t.matches(r'(?i)update|upgrade|lock|bump|renovate')).map(t, taskrunner.recipes[t]).flatten()
    + params.runners.filter(f, file(f)).map(f, lines(f)).flatten()
    + workflows().map(w, steps(w).map(s, s.run.split("\n")).flatten()).flatten())
    .filter(l, !l.matches(params.noise)).exists(l, l.matches(r'\bnpm\s+(ci|clean-install|install-clean)\b|\b(pnpm|yarn|bun)\s+(i|install)\b[^;&|]*--(frozen-lockfile|immutable)\b|\bbun\s+ci\b')
  || ((l.matches(r'\bpnpm\s+(i|install)\b') || (["", "../", "../../", "../../../"].exists(d, file(d + ".yarnrc.yml")) && l.matches(r'\byarn(\s+install)?\s*($|[;&|])')))
      && !l.matches(r'--no-(frozen-lockfile|immutable)')
      && workflows().exists(w, steps(w).exists(s, s.run.split("\n").exists(x, x == l)))))
&& !(taskrunner.recipes.filter(t, !t.matches(r'(?i)update|upgrade|lock|bump|renovate')).map(t, taskrunner.recipes[t]).flatten()
    + workflows().map(w, steps(w).map(s, s.run.split("\n")).flatten()).flatten())
    .filter(l, !l.matches(params.noise)).exists(l, l.matches(r'\bnpm\s+(i|install)(\s+--?[A-Za-z][\w-]*(=\S+)?)*\s*($|[;&|)])|--no-(frozen-lockfile|immutable)\b'))

Parameters

  • noise: ^\s*[@+-]*\s*(\{\{[^}]*\}\}\s*|\$[({][A-Za-z_]+[)}]\s*)?(#|//|echo\b|printf\b)
  • runners: [../Makefile ../justfile ../Justfile ../Taskfile.yml ../Taskfile.yaml ../../Makefile ../../justfile ../../Justfile ../../Taskfile.yml ../../Taskfile.yaml ../../../Makefile ../../../justfile ../../../Justfile ../../../Taskfile.yml ../../../Taskfile.yaml]

Fix

Replace npm install with npm ci in CI and the check targets.

Agent instruction: Switch the CI and task-runner installs to the package manager’s locked mode; if that fails, regenerate the lockfile in a separate commit rather than relaxing the install.

Sources


Generated by fleetlint docs from catalog v0.4.0.