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. - 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.- 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_
exists file_exists— require that at least one file matching any of the given globs exists in the repository.- file_
header file_header— first N lines of each file in scope must match a pattern.- file_
is_ text file_is_text— every file in scope must be detected as text (not binary).- file_
max_ size file_max_size— files in scope must be at mostmax_bytesbytes.- 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.- 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.- io
- Shared I/O helpers for content-reading rules.
- pair
pair— for every file matchingprimary, require a file matching thepartnertemplate to exist somewhere in the tree.- 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.