{"id":19779,"library":"eslint-plugin-header","title":"eslint-plugin-header","description":"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.","status":"active","version":"3.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/Stuk/eslint-plugin-header","tags":["javascript","eslint","eslintplugin"],"install":[{"cmd":"npm install eslint-plugin-header","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-header","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-header","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for the plugin to function","package":"eslint","optional":true}],"imports":[{"note":"The plugin is CommonJS-based but can be imported as default in ESM environments with bundlers like Webpack or Rollup.","wrong":"const header = require('eslint-plugin-header')","symbol":"header","correct":"import header from 'eslint-plugin-header'"}],"quickstart":{"code":"// .eslintrc.json\n{\n  \"plugins\": [\"header\"],\n  \"rules\": {\n    \"header/header\": [2, \"block\", [\"Copyright 2023\", \"My Company\"]]\n  }\n}\n\n// myfile.js (invalid)\nconsole.log('missing header');\n\n// Run ESLint\n// npx eslint myfile.js\n// Error: Missing header comment at top of file","lang":"javascript","description":"Minimum configuration to enforce a block comment header with two lines."},"warnings":[{"fix":"Use absolute paths or ensure the working directory is where the header file resides.","message":"The header file path for 1-argument form is resolved relative to the current working directory, not the eslint config file location.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `lineEndings` as a property in the rule options object; see documentation.","message":"The `lineEndings` option as a settings object in the rule arguments is deprecated in favor of ESLint's built-in line ending handling.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Write patterns with double backslashes: `{\"pattern\": \" Copyright \\\\d{4}\"}`","message":"Regular expression patterns must have double-escaped backslashes (e.g., `\\\\d` for `\\d`) when defined in JSON.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the header is the first comment; shebang lines (#!/usr/bin/env node) are allowed before the header.","message":"The header comment must be the very first non-whitespace content; shebang lines are ignored.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev eslint-plugin-header`","cause":"The plugin is not installed in the project.","error":"ESLint: Failed to load plugin 'header': Cannot find module 'eslint-plugin-header'"},{"fix":"Use severity as first element: `[2, \"block\", ...]` or `[\"error\", \"block\", ...]`","cause":"Using incorrect array syntax; first element is severity (2 or 'error'), but sometimes users mistakenly omit it.","error":"Configuration for rule \"header/header\" is invalid: Value \"[2, \"block\", \"Copyright ...\"]\" is not a valid severity."},{"fix":"Add `\"plugins\": [\"header\"]` to your eslint config.","cause":"The plugin is not registered in the 'plugins' array.","error":"ESLint: The rule 'header/header' does not exist."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}