ESLint plugin to enforce that files begin with a specific comment block, commonly used for copyright notices. The current stable version is 3.1.1, released in 2022. It supports line and block comments, regular expressions for flexible matching, and custom newline counts after the header. Unlike manual checks, it integrates with ESLint's autofix and is suitable for large codebases requiring consistent licensing headers. The package requires eslint >=7.7.0.
npm install eslint-plugin-headerVerified import paths — ran on the pinned version, not inferred.
Minimum configuration to enforce a block comment header with two lines.
Use absolute paths or ensure the working directory is where the header file resides.
Use `lineEndings` as a property in the rule options object; see documentation.
Write patterns with double backslashes: `{"pattern": " Copyright \\d{4}"}`Ensure the header is the first comment; shebang lines (#!/usr/bin/env node) are allowed before the header.
Run `npm install --save-dev eslint-plugin-header`
Use severity as first element: `[2, "block", ...]` or `["error", "block", ...]`
Add `"plugins": ["header"]` to your eslint config.