Registry / testing / eslint-plugin-header

eslint-plugin-header

JSON →
library3.1.1jsnpmunverified

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-header
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-HEAD
E
eslint-plugin-header
testingjavascriptv3.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

header
import header from 'eslint-plugin-header'
const header = require('eslint-plugin-header')
The plugin is CommonJS-based but can be imported as default in ESM environments with bundlers like Webpack or Rollup.

Minimum configuration to enforce a block comment header with two lines.

// .eslintrc.json { "plugins": ["header"], "rules": { "header/header": [2, "block", ["Copyright 2023", "My Company"]] } } // myfile.js (invalid) console.log('missing header'); // Run ESLint // npx eslint myfile.js // Error: Missing header comment at top of file
Debug
Known issues
gotchaThe header file path for 1-argument form is resolved relative to the current working directory, not the eslint config file location.
fix
Use absolute paths or ensure the working directory is where the header file resides.
affects: >=1.0.0
deprecatedThe `lineEndings` option as a settings object in the rule arguments is deprecated in favor of ESLint's built-in line ending handling.
fix
Use `lineEndings` as a property in the rule options object; see documentation.
affects: >=3.0.0
gotchaRegular expression patterns must have double-escaped backslashes (e.g., `\\d` for `\d`) when defined in JSON.
fix
Write patterns with double backslashes: `{"pattern": " Copyright \\d{4}"}`
affects: >=1.0.0
gotchaThe header comment must be the very first non-whitespace content; shebang lines are ignored.
fix
Ensure the header is the first comment; shebang lines (#!/usr/bin/env node) are allowed before the header.
affects: >=1.0.0
Errors
Common errors & fixes
ESLint: Failed to load plugin 'header': Cannot find module 'eslint-plugin-header'
The plugin is not installed in the project.
fix
Run `npm install --save-dev eslint-plugin-header`
Configuration for rule "header/header" is invalid: Value "[2, "block", "Copyright ..."]" is not a valid severity.
Using incorrect array syntax; first element is severity (2 or 'error'), but sometimes users mistakenly omit it.
fix
Use severity as first element: `[2, "block", ...]` or `["error", "block", ...]`
ESLint: The rule 'header/header' does not exist.
The plugin is not registered in the 'plugins' array.
fix
Add `"plugins": ["header"]` to your eslint config.
Upgrade
Version history
3.1.1latest on npm
Audit
Dependencies
eslintoptionalpeer dependency required for the plugin to function
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-header — npm install eslint-plugin-header · libregistry