file_starts_with
Byte-level prefix / suffix check. Works on any bytes (binary safe, unlike file_header).
Check-only: a fix would risk silently duplicating a near-matching prefix. Pair with file_prepend / file_append explicitly if you want auto-repair.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
prefix | string | yes | Required prefix, matched byte-for-byte. |
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”Files missing the required SPDX prefix
Section titled “Files missing the required SPDX prefix”The rule fires on this repository:
src/src/no_header.rssrc/ok.rssrc/wrong_spdx.rsfn x() {}// SPDX-License-Identifier: MITfn main() {}// SPDX-License-Identifier: GPL-3.0fn y() {}With this .alint.yml:
version: 1rules: - id: spdx-header kind: file_starts_with paths: "src/**/*.rs" prefix: "// SPDX-License-Identifier: MIT\n" level: erroralint check reports:
--- src/no_header.rs ----------------------------------------------------------- x error spdx-header 1:1 file does not start with the required prefix
--- src/wrong_spdx.rs ---------------------------------------------------------- x error spdx-header 1:1 file does not start with the required prefix
Summary (2 violations): x 2 errors 0 passing * 1 failingEvery file begins with the SPDX prefix
Section titled “Every file begins with the SPDX prefix”This repository is compliant:
src/src/a.rssrc/b.rs// SPDX-License-Identifier: MITfn main() {}// SPDX-License-Identifier: MITfn x() {}With this .alint.yml:
version: 1rules: - id: spdx-header kind: file_starts_with paths: "src/**/*.rs" prefix: "// SPDX-License-Identifier: MIT\n" level: erroralint check reports:
v All 1 rule(s) passed.