The End-of-Line Checker Plugin is used to verify whether files end with a newline character. Ending file content with a newline is an important coding convention for the following reasons:
\nNote: Binary files (such as
.png,.zip, etc.) are not checked by the plugin — they are automatically skipped.
Add the following to your .cnb.yml:
$:
pull_request:
eof_check:
stages:
- name: check end of line
image: cnbcool/eof-newline-checker:latest
settings:
mode: all
ignore:
- "*.svg"
- ".cnb/web_trigger.yml"
focus:
- "*.md"
- ".gitignore"
- "**/Dockerfile*"
Image Note: The plugin provides two available image addresses. You can choose based on your network environment:
cnbcool/eof-newline-checker:latest(Recommended, from DockerHub)docker.cnb.cool/cnb/plugins/cnbcool/eof-newline-checker:latest(from CNB Registry)Both images are identical in content. You can use either one.
Parameter explanation:
mode: Check mode. This is an optional parameter. Supported values:
all: Full check. This is the default value. Checks whether all files end with a newline character.change: Incremental check. Only checks files that have been changed; other files are not checked.ignore: Ignore list. This is an optional parameter that specifies files to exclude from the check. Supports glob patterns.
focus: Focus list. This is an optional parameter that specifies files to include in the check. Regardless of the mode value, files listed in focus will always be checked. If a file matches both ignore and focus, focus takes priority — the file will be checked. If focus matches a binary file, the plugin will report an error because binary files cannot be checked for trailing newlines.