Skip to content

filename_regex

Basename matches a regex. Use stem: true to match the stem only.


OptionTypeRequiredDefaultDescription
patternstringyesRust regex, automatically anchored with ^…$ by the engine.
stembooleanfalseMatch the file stem (no extension) instead of the full basename.

Plus the common paths, level, id, and when fields. This table is generated from the JSON Schema; option types and defaults are authoritative.

A test file whose name ignores the required test_ prefix

Section titled “A test file whose name ignores the required test_ prefix”

The rule fires on this repository:

tests/
tests/BadNamingHere.rs
tests/test_lexer.rs
tests/test_parser.rs

With this .alint.yml:

version: 1
rules:
- id: tests-named-test-prefix
kind: filename_regex
paths: "tests/**/*.rs"
pattern: "^test_[a-z0-9_]+$"
stem: true
level: error

alint check reports:

Terminal window
--- tests/BadNamingHere.rs -----------------------------------------------------
x error tests-named-test-prefix
filename stem "BadNamingHere" does not match /^test_[a-z0-9_]+$/
Summary (1 violation):
x 1 error
0 passing * 1 failing

Every test file name matches the required test_ prefix

Section titled “Every test file name matches the required test_ prefix”

This repository is compliant:

tests/
tests/test_eval_123.rs
tests/test_lexer.rs
tests/test_parser.rs

With this .alint.yml:

version: 1
rules:
- id: tests-named-test-prefix
kind: filename_regex
paths: "tests/**/*.rs"
pattern: "^test_[a-z0-9_]+$"
stem: true
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.