eslint-plugin-header

An ESLint rule that enforces a required comment header - line or block - at the top of every JS file, with regex matching and autofix support.

Tool
npm
v3.1.1
77stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
29/100Needs Attention
Development Activity0
Maintenance0
Community44
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
54/100Fair
Architecture65
Code Quality68
Innovation38
Learning Curve45

eslint-plugin-header adds a single ESLint rule, header/header, that checks whether each file begins with a specific comment - commonly a copyright or license notice - and reports a violation when it’s missing or doesn’t match. The expected header can be supplied as a literal string, an array of lines, or read from a separate file, and individual lines can be regular expressions with an optional template used for autofixing.

The rule supports both block and line comment styles, a configurable number of newlines after the header, shebang-aware detection so scripts starting with #! still get checked correctly, and OS-appropriate line endings - with eslint --fix able to insert or repair the header automatically whenever every line is fixable.

What You Get

  • header/header rule - A single ESLint rule that checks every file’s leading comment against a configured header.
  • String, array, or file-based config - Define the header inline as a string or array of lines, or point to an external file that’s read and parsed at lint time.
  • Regex line matching with fix templates - Any header line can be a regular expression, with an optional template so eslint --fix still knows what to insert.
  • Autofix support - Missing or incorrect headers can be inserted or replaced automatically via eslint --fix, except when a regex line has no template.
  • Line-ending and shebang awareness - Handles both Unix and Windows line endings and skips over shebang lines before checking for a header.

Common Use Cases

  • Copyright banner enforcement - Teams require every file to open with a company copyright notice, and CI fails the build when it’s missing or altered.
  • License header compliance - Open source projects requiring an SPDX or license notice at the top of every file so contributors don’t strip it accidentally.
  • Generated-file markers - Projects mark auto-generated files with a specific comment header that this rule verifies stays intact.
  • Monorepo-wide header consistency - A shared ESLint config applies the same header rule across many packages to keep file headers consistent.

Under The Hood

Architecture The plugin is a minimal, single-purpose ESLint rule module: index.js exports a rules map with one entry, header, pointing at lib/rules/header.js, which implements the standard ESLint rule shape (meta + create(context)) and registers a Program visitor that runs once per file. A small isolated helper, lib/comment-parser.js, handles the one alternate code path - parsing a header from an external file - by splitting it into the same [commentType, lines] shape the inline-string/array options already produce, so the rest of the rule logic doesn’t need to branch on where the header came from. There is no layering beyond rule-plus-helper, which suits the narrow scope: one rule, one job, no plugin-wide state or shared context to manage.

Tech Stack Plain, pre-ES6 JavaScript (CommonJS require/module.exports, var/function throughout, no TypeScript, no transpilation step) targeting Node’s built-in fs and os modules only - fs.readFileSync for file-based headers and os.EOL for platform-appropriate line endings. The plugin declares eslint as both a dev dependency and a >=7.7.0 peer dependency, is consumed through the standard ESLint plugin/rule configuration surface, and ships with no build tooling - it’s published to npm as-is.

Code Quality Tests exist and are reasonably thorough for the rule’s surface area: tests/lib/rules/header.js uses ESLint’s own RuleTester across a wide range of valid/invalid option combinations (string, array, regex-with-template, file-based, custom newline counts), and a small separate suite covers comment-parser.js directly. A GitHub Actions workflow runs npm test (lint + unit) on push and PR. The codebase itself is untyped ES5-style JavaScript with no modern tooling beyond the project’s own .eslintrc.yml, and error handling is minimal - malformed header files simply throw.

What Makes It Unique The plugin doesn’t introduce a novel technique - header/license-comment enforcement is a well-established category of ESLint rule - but its option surface is more flexible than most single-purpose competitors: per-line regex patterns with separate template values let a header contain data that varies per file (e.g. a copyright year) while still supporting eslint --fix, and the file-based option lets teams share one header definition across configs without duplicating it inline.

Used by 7 apps in this directory

TypeScript
54%
Other

Focalboard

Productivity · Project Management · Collaboration

26,448

Self-hosted, open source project management with Kanban, table, gallery, and calendar views — a privacy-first alternative to Trello, Notion, and Asana.

View details
57
Repo Health
82
Technical
64
Dependency
Built with
TypeScript54%
Go40%
Updated 3 months ago
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,213

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
77
Repo Health
76
Technical
65
Dependency
Built with
TypeScript98%
Updated 2 weeks ago
TypeScript
88%
Apache 2.0

Medplum

Developer Tools · Databases · Authentication

2,657

An open-source, FHIR-native healthcare platform that gives developers a compliant backend, authentication, a React component library, and serverless bots to build clinical applications in weeks instead of years.

View details
93
Repo Health
90
Technical
72
Dependency
Built with
TypeScript88%
MDX10%
Updated yesterday
TypeScript
95%
MIT

melty

Developer Tools · AI Code Assistants · Code Editors

5,443

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
67
Dependency
Built with
TypeScript95%
Updated 1 years ago
TypeScript
85%
GPL 3.0

Notesnook

Note Taking · File Storage · Security

14,533

End-to-end encrypted, open-source note-taking where your data stays yours — even from the server.

View details
90
Repo Health
84
Technical
60
Dependency
Built with
TypeScript85%
JavaScript12%
Updated 2 days ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Code Editors · Automation

28,810

Open-source AI code editor with direct LLM integration and data privacy

View details
46
Repo Health
84
Technical
68
Dependency
Built with
TypeScript95%
Updated 3 months ago
TypeScript
95%
GPL 3.0

Wire

Team Chat · Video Conferencing · Collaboration

1,191

Open source end-to-end encrypted messaging for teams and enterprises — self-host for complete control over your communications and data.

View details
93
Repo Health
8
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search