Skip to content

dir_absent

Directory counterpart of file_absent. The match-and-fire semantics are the same as file_absent — including the .gitignore interaction. A dir_absent rule with paths: "**/target" only fires when target/ exists in the walked tree; if it's gitignored, the walker filters it out and the rule stays silent.

Optional root_only: true (like dir_exists) restricts the check to the repository root: a directory forbidden at the root does not fire on nested directories of the same name. Optional git_tracked_only: true restricts the check to directories that contain at least one git-tracked file. With it set, a developer's locally-built target/ (gitignored, no tracked content) doesn't trigger; a target/ whose contents made it into git's index does. 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.


OptionTypeRequiredDefaultDescription
git_tracked_onlybooleanfalseRestrict matches to directories that contain at least one git-tracked file. Repository unavailability is an analysis failure when enabled. Default false.
root_onlybooleanfalseIf true, only a directory directly at the repository root is forbidden; a nested match with the same name is allowed.

Plus the common paths, level, id, when, and scope_filter 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.

A committed target build directory

Section titled "A committed target build directory"

The rule fires on this repository:

  • Cargo.toml✓
  • target/

    ✗ error no-target

    directory is forbidden (matches [**/target]): target

  • target/debug/
  • target/debug/build.log✓
Cargo.toml
[package]
name = "demo"

With this .alint.yml:

version: 1
rules:
- id: no-target
kind: dir_absent
paths: "**/target"
level: error

alint check reports:

Terminal window
--- target ---------------------------------------------------------------------
x error no-target
directory is forbidden (matches [**/target]): target
Summary (1 violation):
x 1 error
0 passing * 1 failing

A repository without a build directory

Section titled "A repository without a build directory"

This repository is compliant:

  • Cargo.toml✓
  • src/
  • src/main.rs✓
Cargo.toml
[package]
name = "demo"
src/main.rs
fn main() {}

With this .alint.yml:

version: 1
rules:
- id: no-target
kind: dir_absent
paths: "**/target"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.