Skip to content

Conformance

The conformance plugin checks the rules a repository wants every project to follow: each has a README, each package.json has a license and the right repository.directory, the scripts CI runs exist, no package depends on one the repository has banned, and projects with a tag have the files that tag needs. axle boundaries runs them beside its own checks, so CI fails when a project breaks one. It’s written in TypeScript with the plugin kit.

Terminal window
axle add conformance

Then turn on the rules you want under [plugins.conformance] in the root axle.toml:

[plugins.conformance]
source = "npm:@axle-rs/[email protected]"
hash = "sha256-…"
readme = true
license = { tags = ["type:lib"] }
repository = { tags = ["type:lib"], severity = "warning" }
scripts = { scripts = ["build", "test"] }
banned = { packages = ["moment", "request"] }
[[plugins.conformance.files]]
tags = ["type:service"]
files = ["Dockerfile", "CHANGELOG.md"]

and run:

Terminal window
axle boundaries
Rule A project breaks it when Settings
readme its folder has no file named README, of any case and extension
license its package.json has no license, or an empty one
repository its package.json has no repository object with a directory that is the project’s folder, as npm needs for provenance
scripts its package.json lacks one of the scripts scripts, the names, required
banned its package.json lists one of the packages in dependencies, devDependencies, peerDependencies or optionalDependencies packages, required
files one of the files, relative to its folder, doesn’t exist files, required

The rules on package.json leave out projects without one. Each rule is off until its key is set, and takes:

Setting Meaning
severity error, the default, fails axle boundaries; warning is printed and passes; off skips it
tags check only projects with one of these tags

true turns a rule on with neither, and false turns it off. A list of tables, such as [[plugins.conformance.files]], checks the rule once for each, so projects with different tags can need different files.

Each broken rule is a plugin-rule-broken problem, with the file and line when there is one and a hint that says what to add:

error: packages/ui/package.json: has no license (conformance/license)
hint: Add "license" to packages/ui/package.json, such as "MIT".
warning: packages/ui/package.json: has no repository.directory (conformance/repository)
hint: Set "repository" in packages/ui/package.json to an object with "type", "url" and "directory": "packages/ui".
1 problem and 1 warning in 4 projects, 3 dependencies and 12 imports.

--filter and --affected check only the projects they choose, and --json gives each problem’s plugin, rule and severity. A setting the plugin can’t use, such as a rule it doesn’t have, stops axle boundaries with the plugin’s message.