Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-license-header

nikku139.6kMIT0.8.0

Validates the presence of a license header

eslint, eslintplugin, eslint-plugin

readme

eslint-plugin-license-header

CI Code coverage

Rules to validate the presence of license headers in source files.

Installation

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

Usage

Add license-header to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": [
    "license-header"
  ]
}

Header configuration

When enabling the rule specify the license header template as a path:

{
  "rules": {
    "license-header/header": [ "error", "./resources/license-header.js" ]
  }
}

Alternatively, specify the license header as raw text:

{
  "rules": {
    "license-header/header": [
      "error",
      [
          "/***********************************************",
          " * Copyright My Company",
          " * Copyright " + new Date().getFullYear(),
          " ***********************************************/",
      ]
    ]
  }
}

Flat config

In eslint@9 you can consume the library using a flat configuration, too:

import licenseHeader from "eslint-plugin-license-header";

export default [
  {
    files: '**/*.js',
    plugins: {
      'license-header': licenseHeader
    },
    rules: {
      "license-header/header": ...
    }
  }
];

Autofix

You may auto-fix your source files, adding or updating a given license header:

eslint --fix .

Supported rules

License

MIT

changelog

Changelog

All notable changes to eslint-plugin-license-header are documented here. We use semantic versioning for releases.

Unreleased

_Note: Yet to be released changes appear here._

0.8.0

  • FEAT: recognize SPDX-License-Identifier headers (#21)

0.7.0

  • FEAT: recognize @license annotated headers (#19)

0.6.1

  • FIX: play nicely with Svelte and Vue components (#16, #6)

0.6.0

  • FEAT: make ESLint@8 compatible

0.5.0

  • FEAT: add ability to provide header via configuration (#11)

0.4.0

  • FEAT: trim newline around parsed license (#8)

0.3.0

  • FEAT: mark rule as type=layout (#7)

0.2.1

  • CHORE: limit amout of published files

0.2.0

  • FEAT: completely replace whitespace only file contents when adding license
  • FEAT: report license errors on closed next sibling node (or program)
  • CHORE: retrieve leading comments in a eslint@6 compatible way

0.1.3

  • FIX: correct eslint@5+ error when checking empty files

0.1.2

  • FIX: check and add license using existing line separator (#1)

0.1.1

  • FIX: correct rules/header to properly handle replacement of outdated licenses

0.1.0

Initial implementation.