eslint-plugin-simple-header

raw JSON →
1.2.2 verified Mon Apr 27 auth: no javascript

ESLint plugin for enforcing and auto-fixing license headers in source files. Current stable version is 1.2.2. It requires ESLint >=8.41.0 and ships TypeScript type definitions. Designed as a lightweight alternative to eslint-plugin-header with support for template variables (year, author, etc.), multiple comment syntaxes (block, line), and configurable decoration. It uses ESM-only exports and has a flat config-first API.

error Cannot find module 'eslint-plugin-simple-header'
cause Module is ESM-only and not transpiled for CommonJS; your project uses require().
fix
Switch to import or set "type": "module" in package.json.
error Configuration for rule "simple-header/header" is invalid: value must be an array
cause Rule entry is missing array brackets in flat config.
fix
Use "simple-header/header": ["error", { ... }] instead of "simple-header/header": { ... }.
error Cannot read properties of undefined (reading 'year')
cause Missing templates definition for year variable used in header text.
fix
Add templates: { year: { pattern: "\\d{4}", default: "2023" } } to the rule options.
breaking v1.x removes support for legacy ESLint config format (no use .eslintrc)
fix Use flat config (eslint.config.js) with plugins object as shown in docs.
breaking ESM-only module, import fails with require()
fix Use import instead of require; configure package.json with "type": "module" if needed.
deprecated The old syntax for templates used an array [pattern, default] is deprecated in favor of object {pattern, default}
fix Use object syntax: { pattern: '...', default: '...' } instead of array.
gotcha Default year template matches only 4-digit years but does not validate realistic year range
fix Override template pattern if you need custom year validation.
gotcha If no files option is provided, rule applies to all files; may cause linting errors on non-code files
fix Specify files pattern (e.g., ['**/*.js']) to limit scope.
npm install eslint-plugin-simple-header
yarn add eslint-plugin-simple-header
pnpm add eslint-plugin-simple-header

ESLint flat config with simple-header plugin, using template variables for year and author.

import simpleHeader from "eslint-plugin-simple-header";

export default [
  {
    plugins: {
      "simple-header": simpleHeader,
    },
    rules: {
      "simple-header/header": ["error", {
        text: [
          "Copyright (c) {year} {author}",
          "SPDX-License-Identifier: MIT",
        ],
        templates: {
          year: { pattern: "\\d{4}", default: new Date().getFullYear().toString() },
          author: { pattern: ".*", default: "John Doe" },
        },
      }],
    },
  },
];