Skip to content

file_content_matches

File contents must contain at least one match for a regex.

Fix: file_append — append declared content.

OptionTypeRequiredDefaultDescription
patternstringyesRust regex. File contents 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.

The rule fires on this repository:

README.md
README.md
# Project
A short description.

With this .alint.yml:

version: 1
rules:
- id: spdx-in-readme
kind: file_content_matches
paths: "README.md"
pattern: "SPDX-License-Identifier"
level: warning

alint check reports:

Terminal window
--- README.md ------------------------------------------------------------------
! warning spdx-in-readme
content does not match required pattern /SPDX-License-Identifier/
Summary (1 violation):
! 1 warning
0 passing * 1 failing

This repository is compliant:

README.md
README.md
# Project
SPDX-License-Identifier: Apache-2.0
A short description.

With this .alint.yml:

version: 1
rules:
- id: spdx-in-readme
kind: file_content_matches
paths: "README.md"
pattern: "SPDX-License-Identifier"
level: warning

alint check reports:

Terminal window
v All 1 rule(s) passed.