npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-header-license

v1.0.0

Published

ESLint plugin to enforce license header

Readme

An ESLint plugin that enforces the presence of a license header in your source files. This plugin automatically adds and maintains license headers in your codebase, supporting various file types and comment styles.

Table of Contents

Features

  • 🔍 Automatically checks for license headers in your files
  • 🛠️ Auto-fixes missing license headers
  • 📝 Supports multiple file types:
    • JavaScript/TypeScript (.js, .ts, .jsx, .tsx)
    • HTML (.html)
    • Styles (.css)

Installation

npm install --save-dev eslint-plugin-header-license

Usage

  1. Create a license template file (e.g., license.txt) with your license header content.

  2. Add the plugin to your ESLint configuration:

{
  "plugins": [
    "header-license"
  ],
  "rules": {
    "header-license/header-license": [2, {
      "file": "path/to/file/license.txt"
    }]
  }
}

Configuration

The plugin accepts the following configuration options:

| Option | Type | Required | Description | |--------|--------|----------|-----------------------------------| | file | string | Yes | Path to the license template file |

Examples

Copyright (c) 2024 Your Name
Licensed under the MIT License.

JavaScript/TypeScript Files

/*
 * Copyright (c) 2024 Your Name
 * Licensed under the MIT License.
*/
const example = 'This is my code';

HTML Files

<!--
 -- Copyright (c) 2024 Your Name
 -- Licensed under the MIT License.
-->
<!DOCTYPE html>
<html>
  <!-- Your HTML content -->
</html>

CSS Files

/*
 * Copyright (c) 2024 Your Name
 * Licensed under the MIT License.
*/
.example {
  color: blue;
}

Auto-fix

The plugin supports ESLint's auto-fix feature. When enabled, it will automatically add the license header to files that are missing it.

eslint --fix your-file.js

Or for all files

eslint . --fix

Adding more file types

Feel free to create an issue on the GitHub page with a suggestion to add support for a new parser for the plugin.

Error Handling

The plugin reports the following errors:

Configuration Errors

  • License file path is required
    • Occurs when the file option is not provided in the ESLint configuration
    • Fix: Add the file option to your ESLint config:
    {
      "rules": {
        "header-license/header-license": ["error", {
          "file": "./LICENSE"  // Required
        }]
      }
    }

Validation Errors

  • Failed to read license file: [error message]

    • Occurs when the plugin cannot read the specified license file
    • Common causes:
      • File doesn't exist
      • Insufficient permissions
      • Invalid file path
    • Fix: Ensure the license file exists and is accessible
  • Missed license header

    • Occurs when the file doesn't have a license header at the beginning
    • The plugin will automatically fix this by adding the header
    • Run eslint --fix to apply the fix
  • License header is incorrect

    • Occurs when the file has a license header but it doesn't match the required format
    • The plugin will automatically fix this by replacing the incorrect header
    • Run eslint --fix to apply the fix

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for more information.