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/.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
allow | string or list of string | yes | Basename glob(s) accepted as direct children. Anything else is a violation. | |
select | string | yes | Glob 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.
Example
Section titled “Example”Stray non-Rust files under src
Section titled “Stray non-Rust files under src”The rule fires on this repository:
src/src/a.rssrc/b.rssrc/notes.txtsrc/stray.pyWith this .alint.yml:
version: 1rules: - id: src-only-rs kind: dir_only_contains select: "src" allow: ["*.rs"] level: erroralint check reports:
--- 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 failingThe src directory holds only Rust files
Section titled “The src directory holds only Rust files”This repository is compliant:
src/src/a.rssrc/b.rssrc/mod.rsWith this .alint.yml:
version: 1rules: - id: src-only-rs kind: dir_only_contains select: "src" allow: ["*.rs"] level: erroralint check reports:
v All 1 rule(s) passed.