Skip to content

dir_only_contains

Every direct-child file of a directory matching select: must match at least one glob in allow:. Catches stray test data in src/.

OptionTypeRequiredDefaultDescription
allowstring or list of stringyesBasename glob(s) accepted as direct children. Anything else is a violation.
selectstringyesGlob selecting the directories to enumerate.

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.

The rule fires on this repository:

src/
src/a.rs
src/b.rs
src/notes.txt
src/stray.py

With this .alint.yml:

version: 1
rules:
- id: src-only-rs
kind: dir_only_contains
select: "src"
allow: ["*.rs"]
level: error

alint check reports:

Terminal window
--- src/notes.txt --------------------------------------------------------------
x error src-only-rs
src/notes.txt is not allowed in src (allow: [*.rs])
--- src/stray.py ---------------------------------------------------------------
x error src-only-rs
src/stray.py is not allowed in src (allow: [*.rs])
Summary (2 violations):
x 2 errors
0 passing * 1 failing

This repository is compliant:

src/
src/a.rs
src/b.rs
src/mod.rs

With this .alint.yml:

version: 1
rules:
- id: src-only-rs
kind: dir_only_contains
select: "src"
allow: ["*.rs"]
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.