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_caseandpath_case. - command
command— shell out to an external CLI per matched file.- dir_
absent dir_absent— no directory matchingpathsmay exist.- dir_
contains dir_contains— every directory matchingselectmust have at least one direct child matching each glob inrequire. Sugar overfor_each_dir+file_existsfor the common shape “this dir must have X, Y, and Z.”- dir_
exists dir_exists— at least one directory matchingpathsmust exist.- dir_
only_ contains dir_only_contains— every direct child file of a directory matchingselect:must match at least one glob inallow:. Subdirectories are not checked (usedir_absentif you need to forbid nested directories).- every_
matching_ has every_matching_has— every file OR directory matchingselectmust satisfy every rule inrequire. Sugar overfor_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+xbit set (require: true) or does not (require: false).- executable_
has_ shebang executable_has_shebang— every+xfile in scope must begin with a shebang line (#!).- file_
absent file_absent— emit a violation for every file matchingpaths.- 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 MOSTmax_lineslines. Mirror ofcrate::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 mostmax_bytesbytes.- file_
min_ lines file_min_lines— files in scope must have at leastmin_lineslines.- file_
min_ size file_min_size— files in scope must be at leastmin_bytesbytes.- 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
Fixerimplementations. - for_
each_ dir for_each_dir— iterate over every directory matchingselect:and evaluate a nestedrequire: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 matchingselect:and evaluate a nestedrequire:block against each. Same mechanics ascrate::for_each_dir— differs only in iterating files instead of directories from theFileIndex.- indent_
style indent_style— every non-blank line in each file in scope must indent with the configured style:tabsorspaces.- io
- Shared I/O helpers for content-reading rules.
- line_
endings line_endings— every line in each file in scope must use the configured line ending (lforcrlf). Mixed endings in a single file fail.- line_
max_ width line_max_width— cap on characters per line.- 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.gitmodulesfile 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 matchingprimary, require a file matching thepartnertemplate to exist somewhere in the tree.- shebang_
has_ executable shebang_has_executable— every file that starts with#!must have the Unix+xbit set.- structured_
path - Structured-query rule family:
{json,yaml,toml}_path_{equals,matches}. - unique_
by unique_by— flag any group of files (matchingselect:) that share the same renderedkey. 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.