dir_contains
Every directory matching select: must contain files matching every glob in require:. Sugar for a common for_each_dir shape.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
require | RequireList | yes | Basename glob(s): every dir matching select must have at least one child matching each. | |
select | string | yes | Glob selecting the directories to check. |
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 missing its README or license
Section titled “A package directory missing its README or license”The rule fires on this repository:
packages/packages/alpha/packages/alpha/LICENSEpackages/alpha/README.mdpackages/beta/packages/beta/README.mdpackages/gamma/packages/gamma/LICENSEMIT# alpha# betaMITWith this .alint.yml:
version: 1rules: - id: packages-have-readme-and-license kind: dir_contains select: "packages/*" require: ["README.md", "LICENSE*"] level: erroralint check reports:
--- packages/beta -------------------------------------------------------------- x error packages-have-readme-and-license packages/beta is missing a child matching "LICENSE*"
--- packages/gamma ------------------------------------------------------------- x error packages-have-readme-and-license packages/gamma is missing a child matching "README.md"
Summary (2 violations): x 2 errors 0 passing * 1 failingEvery package directory has a README and a license
Section titled “Every package directory has a README and a license”This repository is compliant:
packages/packages/alpha/packages/alpha/LICENSEpackages/alpha/README.mdpackages/beta/packages/beta/LICENSE-APACHEpackages/beta/README.mdMIT# alphaApache-2.0 text# betaWith this .alint.yml:
version: 1rules: - id: packages-have-readme-and-license kind: dir_contains select: "packages/*" require: ["README.md", "LICENSE*"] level: erroralint check reports:
v All 1 rule(s) passed.