Skip to content

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).

OptionTypeRequiredDefaultDescription
linesinteger (>= 1)20Number of leading lines to consider.
patternstringyesRust 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.

Section titled “A source file missing its copyright header”

The rule fires on this repository:

src/
src/a.rs
src/b.rs
src/a.rs
fn a() {}
src/b.rs
// Copyright 2026
// SPDX-License-Identifier: Apache-2.0
fn b() {}

With this .alint.yml:

version: 1
rules:
- id: copyright-header
kind: file_header
paths: "src/**/*.rs"
pattern: "(?s)Copyright"
lines: 3
level: error

alint check reports:

Terminal window
--- 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 failing

This repository is compliant:

src/
src/a.rs
src/b.rs
src/a.rs
// Copyright 2026
fn a() {}
src/b.rs
// Copyright 2026
// SPDX-License-Identifier: Apache-2.0
fn b() {}

With this .alint.yml:

version: 1
rules:
- id: copyright-header
kind: file_header
paths: "src/**/*.rs"
pattern: "(?s)Copyright"
lines: 3
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.