filename_regex
Basename matches a regex. Use stem: true to match the stem only.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
pattern | string | yes | Rust regex, automatically anchored with ^…$ by the engine. | |
stem | boolean | false | Match 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.
Example
Section titled “Example”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.rstests/test_lexer.rstests/test_parser.rsWith this .alint.yml:
version: 1rules: - id: tests-named-test-prefix kind: filename_regex paths: "tests/**/*.rs" pattern: "^test_[a-z0-9_]+$" stem: true level: erroralint check reports:
--- 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 failingEvery 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.rstests/test_lexer.rstests/test_parser.rsWith this .alint.yml:
version: 1rules: - id: tests-named-test-prefix kind: filename_regex paths: "tests/**/*.rs" pattern: "^test_[a-z0-9_]+$" stem: true level: erroralint check reports:
v All 1 rule(s) passed.