IF Commons GitHub

logical/declared

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-repoctl-sync FR-010

The packages a library imports and does not declare (commons repoctl 0003-repoctl-sync FR-010): a library job of CI installs only its own folder, so a package that a source, a test or a tool of the library imports by name (and node: imports, which need @types/node) must be in its dependencies or devDependencies, or the job fails where a checkout with the whole repository installed passes. Pure: it reads the texts it is given.

import { undeclaredFindings } from "./declared.ts";
const lib = { name: "a", folder: "commons/a", manifest: '{"devDependencies":{}}', sources: [{ path: "commons/a/suite/x.test.ts", text: 'import { x } from "left-pad";' }] };
undeclaredFindings([lib]).length; // 1

Source: commons/repoctl/src/logical/declared.ts

3 of 12 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

logical.DeclaredInputtypeno test imports it
type DeclaredInput = { readonly name: string; readonly folder: string; readonly manifest: string; readonly sources: readonly Source[] };

A library as this check reads it: its folder, the text of its package.json and the TypeScript of its sources, suite and tools.

logical.importedPackageOffunctionno test imports it
function importedPackageOf(specifier: string): string | undefined

The package a specifier names, node: for a built-in of Node, or undefined for a relative path, a path, a template and a built-in of Bun.

logical.withoutBlockCommentsfunctionno test imports it
function withoutBlockComments(text: string): string

The text of a source without its block comments, whose examples import what the library does not.

logical.importedPackagesfunctionno test imports it
function importedPackages(source: Source): ReadonlyMap<string, number>

The packages a source imports, each with the first line that does.

logical.declaredNamesfunctionno test imports it
function declaredNames(manifest: string): ReadonlySet<string>

The names a manifest declares under dependencies, devDependencies, peerDependencies and optionalDependencies; none where it cannot be read.

logical.undeclaredFindingsfunctionno test imports it
function undeclaredFindings(libraries: readonly DeclaredInput[]): readonly Finding[]

A finding for each package a library imports and does not declare, naming the first file and line that imports it.

DeclaredInputtypeno test imports it
type DeclaredInput = { readonly name: string; readonly folder: string; readonly manifest: string; readonly sources: readonly Source[] };

A library as this check reads it: its folder, the text of its package.json and the TypeScript of its sources, suite and tools.

importedPackageOffunctionno test imports it
function importedPackageOf(specifier: string): string | undefined

The package a specifier names, node: for a built-in of Node, or undefined for a relative path, a path, a template and a built-in of Bun.

withoutBlockCommentsfunctionno test imports it
function withoutBlockComments(text: string): string

The text of a source without its block comments, whose examples import what the library does not.

importedPackagesfunction
function importedPackages(source: Source): ReadonlyMap<string, number>

The packages a source imports, each with the first line that does.

Imported by 1 test of the run (1 passed, 0 failed): the library's results

declaredNamesfunction
function declaredNames(manifest: string): ReadonlySet<string>

The names a manifest declares under dependencies, devDependencies, peerDependencies and optionalDependencies; none where it cannot be read.

Imported by 1 test of the run (1 passed, 0 failed): the library's results

undeclaredFindingsfunction
function undeclaredFindings(libraries: readonly DeclaredInput[]): readonly Finding[]

A finding for each package a library imports and does not declare, naming the first file and line that imports it.

Imported by 1 test of the run (1 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.