dir_exists
Directory counterpart of file_exists. Every match must correspond to a real directory in the walked tree.
Optional root_only: true (like file_exists) requires the match to be a
directory directly at the repository root, not nested.
Optional git_tracked_only: true further requires that the directory contain at least one tracked file. A tree with a docs/ checked out from a stale clone where every file was later removed via git rm would fail under this stricter check. If Git cannot be run or the lint root is not a Git repository, the rule reports a resource_read analysis failure. See The walker and .gitignore for the full semantics.
When to use it: for the directories a repository's tooling or contributors rely on being there: a docs/ tree the site build reads, .github/workflows/ for CI, tests/ next to the sources. Listing several paths accepts any one of them, so paths: ["doc", "docs"] passes with either name.
One match is enough: a glob such as packages/*/src passes as soon as one package has a src/; it fails only when nothing matches at all. To require a src/ in every package, iterate with for_each_dir and nest a dir_exists per directory.
With fix: {dir_create: {}}, paths must name one directory in normal form, such as docs/adr: no glob, no . or .., and no leading, trailing or doubled /. The rule matches paths against the walked tree, which names the directory docs/adr, so docs/ or ./docs would never pass, and the configuration fails to load instead.
Options
Section titled "Options"| Option | Type | Required | Default | Description |
|---|---|---|---|---|
git_tracked_only | boolean | false | Restrict matches to directories that contain at least one git-tracked file. Repository unavailability is an analysis failure when enabled. Default false. | |
root_only | boolean | false | If true, only a directory directly at the repository root satisfies the rule; a nested match does not. |
Plus the common paths, level, id, when, and fix fields. This kind does not support expect_matches; its empty-scope semantics are kind-specific. This table is generated from the JSON Schema; option types and defaults are authoritative.
Example
Section titled "Example"A repository missing its src directory
Section titled "A repository missing its src directory"The rule fires on this repository:
- the repository
✗ error has-src
expected a directory matching [src]
- Cargo.toml✓
[package]name = "demo"With this .alint.yml:
version: 1rules: - id: has-src kind: dir_exists paths: "src" level: erroralint check reports:
--- Repository-level ----------------------------------------------------------- x error has-src expected a directory matching [src]
Summary (1 violation): x 1 error 0 passing * 1 failingA repository with a src directory
Section titled "A repository with a src directory"This repository is compliant:
- Cargo.toml✓
- src/
- src/main.rs✓
[package]name = "demo"fn main() {}With this .alint.yml:
version: 1rules: - id: has-src kind: dir_exists paths: "src" level: erroralint check reports:
v All 1 rule(s) passed.