SKY-Q408 · Quality, structure and performance
Undeclared npm dependency
A literal source import, type reference or supported configuration use names an npm package that neither the owning package.json nor an ancestor workspace declares. With strict_dependencies = true, production source of a published package needs its own declaration.
- Languages
- TypeScript, JavaScript, 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
Why it matters
The source may work only because a different workspace or a transitive dependency happened to install the package. A clean install or dependency upgrade can then fail.
What Skylos flags
{"name":"shop","version":"1.0.0","main":"src/app.js","dependencies":{}}import "chalk";What Skylos leaves alone
{"name":"shop","version":"1.0.0","dependencies":{"chalk":"^5.0.0"}}Why Skylos leaves it alone
The owning manifest explicitly declares the imported package.
How Skylos decides
- Runs with quality analysis and reads package manifests without installing packages or running package scripts.
- Assigns source files to their nearest package.json; a nested one that declares no name, dependencies, workspaces, scripts or binaries (a marker holding only
type) does not own files. Reads literal imports, re-exports, require/import calls,/// <reference types>directives, tsconfigtypesentries and supported literal tool configuration, including Vue, Svelte and Astro script blocks and top-level MDX ESM (fenced code and prose are ignored). Built-ins, local paths, proven workspace aliases and framework module aliases such as Docusaurus @theme/* are excluded. - Node resolution walks up to ancestor node_modules, so an ancestor workspace's declaration satisfies every file below it by default; the receipt counts published production imports that rely on one (
ancestor_declared_production_imports). With[tool.skylos] strict_dependencies = truepublished production source needs its own declaration and the finding names theancestor_manifest. A sibling workspace's declaration never counts. - A workspace package that tsconfig
pathsor a readable bundler alias maps to project source is not reported outside published production source. Fixture text that codemod harnesses read (__testfixtures__/,__fixtures__/,fixtures/**/input.*/output.*) and JSDocimport()types outside published production source are usage evidence only. A type-only import is satisfied by the matching@types/declaration. - Stylesheets are usage evidence only, except unambiguous package references (Sass pkg:name URLs and Tailwind @plugin names); a bare CSS @import can be a local file or load path and is never reported.
- Checks dependencies, devDependencies, optionalDependencies and peerDependencies in the owner. Reports MEDIUM at the source or configuration use when its package is missing.
- Does not claim that the registry package exists or that an SDK API is valid. Unknown loaders and unread source are recorded in analysis_summary.npm_dependency_analysis and cannot prove dependency non-use.
How to fix it
Declare the intended package in the manifest that owns the source, using an appropriate dependency section and version, or remove the unwanted import.
Removed: {"name":"shop","version":"1.0.0","main":"src/app.js","dependencies":{}}Added: {"name":"shop","version":"1.0.0","dependencies":{"chalk":"^5.0.0"}}When it can be wrong
- A deployment may deliberately provide an undeclared package globally; the repository alone does not declare that contract.
- A published package's production file that is never shipped (excluded from
filesor the build) is still treated as published source. - Only bounded literal source/configuration forms are read. Unknown configuration is recorded rather than executed.
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-Q408"]to disable this rule project-wide.