file_header
The first N lines must match a regex (line-oriented). For a byte-level prefix check, prefer file_starts_with.
Fix: file_prepend — inject declared content at the top (preserves UTF-8 BOM).
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
lines | integer (>= 1) | 20 | Number of leading lines to consider. | |
pattern | string | yes | Rust regex. The first lines lines of each file in scope must match. |
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 source file missing its copyright header
Section titled “A source file missing its copyright header”The rule fires on this repository:
src/src/a.rssrc/b.rsfn a() {}// Copyright 2026// SPDX-License-Identifier: Apache-2.0fn b() {}With this .alint.yml:
version: 1rules: - id: copyright-header kind: file_header paths: "src/**/*.rs" pattern: "(?s)Copyright" lines: 3 level: erroralint check reports:
--- src/a.rs ------------------------------------------------------------------- x error copyright-header 1:1 first 3 line(s) do not match required header /(?s)Copyright/
Summary (1 violation): x 1 error 0 passing * 1 failingEvery source file carries the header
Section titled “Every source file carries the header”This repository is compliant:
src/src/a.rssrc/b.rs// Copyright 2026fn a() {}// Copyright 2026// SPDX-License-Identifier: Apache-2.0fn b() {}With this .alint.yml:
version: 1rules: - id: copyright-header kind: file_header paths: "src/**/*.rs" pattern: "(?s)Copyright" lines: 3 level: erroralint check reports:
v All 1 rule(s) passed.