Skip to main content

SKY-Q409 · Quality, structure and performance

Unlisted npm script binary

Medium

A simple package script invokes an npm binary whose provider is not declared by that package or an ancestor. System tools and dynamically expanded scripts do not establish a missing provider.

Languages
package.json
Turned on by
skylos . --quality
Quality gate
counted toward the gate limits (full and diff scans). Reported as quality; counts toward max_quality.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A build can succeed only because the developer has a globally installed tool. A clean environment lacks that undeclared provider and the script stops working.

What Skylos flags

package.json · JSONReported on line 1
{"name":"shop","scripts":{"build":"tsc --noEmit"}}
src/app.ts · TypeScript
export const version = "1.0.0";

What Skylos leaves alone

package.json · JSON
{"name":"shop","scripts":{"build":"tsc --noEmit"},"devDependencies":{"typescript":"^5.0.0"}}

src/app.ts: same as in the flagged example.

Why Skylos leaves it alone

The typescript declaration supplies the known tsc binary; an ancestor tooling declaration can also supply workspace scripts.

How Skylos decides

  1. Reads command heads in package.json scripts without executing them. Each &&, ;, || and | segment is read on its own; $VAR arguments, assignments, redirections and command substitutions do not hide the command, and yarn --cwd <dir>, npm --prefix <dir>, pnpm -C, pnpm --filter and yarn workspace run the target package's script there or resolve the binary in the target's lineage.
  2. Resolves a command through literal bin metadata from installed or workspace package manifests, the bin entries a lockfile records (package-lock.json, Yarn Berry yarn.lock, bun.lock), a map of well-known CLIs whose package name differs (tsc to typescript, ng to @angular/cli, ngc to @angular/compiler-cli, svelte-package to @sveltejs/package, changeset to @changesets/cli and others), and otherwise assumes the command names its package. A provider declared in the package or an ancestor counts as available. Shareable configs, plugins, presets and @types/ packages never provide a tool binary.
  3. Reads through cross-env, env, concurrently and npm-run-all style runners. npx, pnpm dlx and unknown package-manager shorthands can fetch or resolve providers indirectly, so they never report a missing provider.
  4. An unknown command first holds back declared dependencies that could plausibly provide it, meaning not installed and name-related to the command. Only those dependencies abstain from SKY-U005; every other dependency is still checked.
  5. Reports MEDIUM on the script line when no declared dependency could provide the command, the command is not a system tool or shell builtin (psql, docker, make, readarray and similar) and the script is not dynamic. An expanded command name, subshells, node -e code and opaque wrappers remain unresolved and are recorded in analysis_summary.npm_dependency_analysis. CI and container commands count as dependency use but are never reported here.

How to fix it

Add the intended binary provider to this package or shared ancestor tooling, or replace the script with a declared tool.

package.json · JSON · the fix, against the flagged file
Removed: {"name":"shop","scripts":{"build":"tsc --noEmit"}}Added: {"name":"shop","scripts":{"build":"tsc --noEmit"},"devDependencies":{"typescript":"^5.0.0"}}

When it can be wrong

  • An operator may intentionally install the binary globally, but that contract is outside this manifest.
  • A tool installed outside npm under a name Skylos does not list as a system command is reported; suppress it or invoke it through an explicit path.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Set [tool.skylos] ignore = ["SKY-Q409"] to disable this rule project-wide.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.