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"]).
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
require | list of nested rule | yes | One or more nested rules that every file or directory matching select must satisfy. | |
select | SelectSpec | yes | Glob(s) selecting the files/dirs to iterate: a single glob, or a list with !-prefixed excludes (e.g. ["packages/*", "!packages/internal"]). | |
when_iter | string | null | Per-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.
Example
Section titled “Example”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.jsonpackages/beta/packages/beta/README.mdpackages/gamma/packages/gamma/package.json{}# beta{}With this .alint.yml:
version: 1rules: - id: every-pkg-has-package-json kind: every_matching_has select: "packages/*" require: - kind: file_exists paths: "{path}/package.json" level: erroralint check reports:
--- 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 failingEvery 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.jsonpackages/beta/packages/beta/package.json{}{}With this .alint.yml:
version: 1rules: - id: every-pkg-has-package-json kind: every_matching_has select: "packages/*" require: - kind: file_exists paths: "{path}/package.json" level: erroralint check reports:
v All 1 rule(s) passed.