Skip to main content

Crate alint_rules

Crate alint_rules 

Source
Expand description

Built-in rule implementations for alint.

Rules are registered into an alint_core::RuleRegistry via register_builtin. Each kind has its own submodule.

Modules§

case
Case-convention detectors used by filename_case and path_case.
command
command — shell out to an external CLI per matched file.
commented_out_code
commented_out_code — heuristic detector for blocks of commented-out source code (as opposed to prose comments, license headers, doc comments, or ASCII banners).
dir_absent
dir_absent — no directory matching paths may exist.
dir_contains
dir_contains — every directory matching select must have at least one direct child matching each glob in require. Sugar over for_each_dir + file_exists for the common shape “this dir must have X, Y, and Z.”
dir_exists
dir_exists — at least one directory matching paths must exist.
dir_only_contains
dir_only_contains — every direct child file of a directory matching select: must match at least one glob in allow:. Subdirectories are not checked (use dir_absent if you need to forbid nested directories).
every_matching_has
every_matching_has — every file OR directory matching select must satisfy every rule in require. Sugar over for_each_file + for_each_dir: one rule that iterates both entry kinds so users who don’t care whether a glob matches files or dirs can write a single rule instead of two.
executable_bit
executable_bit — assert every file in scope either has the Unix +x bit set (require: true) or does not (require: false).
executable_has_shebang
executable_has_shebang — every +x file in scope must begin with a shebang line (#!).
file_absent
file_absent — emit a violation for every file matching paths.
file_content_forbidden
file_content_forbidden — files in scope must NOT match a regex.
file_content_matches
file_content_matches — every file in scope must match a regex.
file_ends_with
file_ends_with — every file in scope must end with the configured suffix (byte-level).
file_exists
file_exists — require that at least one file matching any of the given globs exists in the repository.
file_footer
file_footer — last N lines of each file in scope must match a pattern.
file_hash
file_hash — assert a file’s SHA-256 equals a declared hex string.
file_header
file_header — first N lines of each file in scope must match a pattern.
file_is_ascii
file_is_ascii — every byte in the file must be < 0x80.
file_is_text
file_is_text — every file in scope must be detected as text (not binary).
file_max_lines
file_max_lines — files in scope must have AT MOST max_lines lines. Mirror of crate::file_min_lines; shares the line-counting semantics so the two compose cleanly when both are applied to the same file.
file_max_size
file_max_size — files in scope must be at most max_bytes bytes.
file_min_lines
file_min_lines — files in scope must have at least min_lines lines.
file_min_size
file_min_size — files in scope must be at least min_bytes bytes.
file_shebang
file_shebang — first line of each file in scope must match a shebang regex.
file_starts_with
file_starts_with — every file in scope must begin with the configured prefix (byte-level).
filename_case
filename_case — every file in scope must have a basename whose stem matches a case convention.
filename_regex
filename_regex — every file in scope must have a basename matching a regex. Anchored with ^...$ automatically; use the full basename (including extension) in your pattern.
final_newline
final_newline — every non-empty file in scope must end with a newline byte.
fixers
Shared Fixer implementations, grouped by family.
for_each_dir
for_each_dir — iterate over every directory matching select: and evaluate a nested require: block against each. Path-template tokens in the nested specs are pre-substituted per iteration using the iterated directory as the anchor.
for_each_file
for_each_file — iterate over every file matching select: and evaluate a nested require: block against each. Same mechanics as crate::for_each_dir — differs only in iterating files instead of directories from the FileIndex.
git_blame_age
git_blame_age — fire on lines matching a regex whose git blame author-time is older than a configured threshold.
git_commit_message
git_commit_message — assert commit messages match a shape (regex, max subject length, body required).
git_no_denied_paths
git_no_denied_paths — fire when any tracked file matches a configured denylist of glob patterns.
indent_style
indent_style — every non-blank line in each file in scope must indent with the configured style: tabs or spaces.
io
Shared I/O helpers for content-reading rules.
json_schema_passes
json_schema_passes — assert that a set of JSON / YAML / TOML files validates against a JSON Schema.
line_endings
line_endings — every line in each file in scope must use the configured line ending (lf or crlf). Mixed endings in a single file fail.
line_max_width
line_max_width — cap on characters per line.
markdown_paths_resolve
markdown_paths_resolve — backticked workspace paths in markdown files must resolve to real files or directories.
max_consecutive_blank_lines
max_consecutive_blank_lines — cap the number of blank lines that may appear in a row. A “blank” line is one whose content is empty or only spaces/tabs.
max_directory_depth
max_directory_depth — cap the depth of any path in scope.
max_files_per_directory
max_files_per_directory — cap how many files may live directly under any directory in scope (non-recursive).
no_bidi_controls
no_bidi_controls — flag Unicode bidirectional control characters in source.
no_bom
no_bom — flag files that start with a byte-order mark.
no_case_conflicts
no_case_conflicts — flag two paths that differ only by case (e.g. README.md + readme.md). Such pairs cannot coexist on case-insensitive filesystems (macOS HFS+/APFS default, Windows NTFS in its default mode), so committing them breaks checkouts for those developers.
no_empty_files
no_empty_files — flag zero-byte files in scope.
no_illegal_windows_names
no_illegal_windows_names — reject path components that Windows can’t represent or restore from a checkout.
no_merge_conflict_markers
no_merge_conflict_markers — flag files that still carry unresolved git-merge conflict markers.
no_submodules
no_submodules — flag the presence of a .gitmodules file at the repo root.
no_symlinks
no_symlinks — flag tracked paths that are symbolic links.
no_trailing_whitespace
no_trailing_whitespace — every line in each file in scope must not end with a space or tab.
no_zero_width_chars
no_zero_width_chars — flag invisible zero-width characters that can hide text, break identifiers, or leak data.
pair
pair — for every file matching primary, require a file matching the partner template to exist somewhere in the tree.
shebang_has_executable
shebang_has_executable — every file that starts with #! must have the Unix +x bit set.
structured_path
Structured-query rule family: {json,yaml,toml}_path_{equals,matches}.
unique_by
unique_by — flag any group of files (matching select:) that share the same rendered key. The key is a path template evaluated per matched file; default is {basename} (catches any two files with the same name regardless of directory).

Functions§

builtin_registry
Convenience constructor that returns a fresh registry pre-populated with every built-in rule.
register_builtin
Register every built-in rule kind into the given registry.