Skip to content

every_matching_has

For every file or directory matching select:, every nested rule under require: must be satisfied. Lightweight sibling of pair that iterates both file and directory entries. select: is a single glob or a list with !-prefixed excludes (e.g. ["packages/*", "!packages/internal"]).


OptionTypeRequiredDefaultDescription
requirelist of nested ruleyesOne or more nested rules that every file or directory matching select must satisfy.
selectSelectSpecyesGlob(s) selecting the files/dirs to iterate: a single glob, or a list with !-prefixed excludes (e.g. ["packages/*", "!packages/internal"]).
when_iterstringnullPer-iteration when: filter (same semantics as for_each_dir’s when_iter).

Plus the common level, id, and when fields. This rule analyses the whole repository, so it takes no paths. This table is generated from the JSON Schema; option types and defaults are authoritative.

A package directory without a package.json

Section titled “A package directory without a package.json”

The rule fires on this repository:

packages/
packages/alpha/
packages/alpha/package.json
packages/beta/
packages/beta/README.md
packages/gamma/
packages/gamma/package.json
packages/alpha/package.json
{}
packages/beta/README.md
# beta
packages/gamma/package.json
{}

With this .alint.yml:

version: 1
rules:
- id: every-pkg-has-package-json
kind: every_matching_has
select: "packages/*"
require:
- kind: file_exists
paths: "{path}/package.json"
level: error

alint check reports:

Terminal window
--- packages/beta --------------------------------------------------------------
x error every-pkg-has-package-json
expected a file matching [packages/beta/package.json]
Summary (1 violation):
x 1 error
0 passing * 1 failing

Every package directory has a package.json

Section titled “Every package directory has a package.json”

This repository is compliant:

packages/
packages/alpha/
packages/alpha/package.json
packages/beta/
packages/beta/package.json
packages/alpha/package.json
{}
packages/beta/package.json
{}

With this .alint.yml:

version: 1
rules:
- id: every-pkg-has-package-json
kind: every_matching_has
select: "packages/*"
require:
- kind: file_exists
paths: "{path}/package.json"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.