eslint-plugin-notice

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript

ESLint plugin that enforces a copyright or license notice at the top of source files. Version 1.0.0 provides a single rule `notice/notice` with an `--fix` option to automatically prepend missing headers. Unlike generic file-header linting, it uses configurable patterns, templates, and per-file overrides. Compatible with ESLint 3+. Low churn (single stable release); good for projects requiring consistent legal boilerplate.

error Definition for rule 'notice/notice' was not found
cause The plugin is not registered in the ESLint config.
fix
Add 'plugins: ["notice"]' to your .eslintrc.
error Cannot find module 'eslint-plugin-notice'
cause Package is not installed or missing from node_modules.
fix
Run 'npm install eslint-plugin-notice --save-dev'.
error Invalid option 'nonMatchingTolerance' for rule notice/notice
cause Misspelled or deprecated option name; use 'onNonMatchingHeader'.
fix
Replace 'nonMatchingTolerance' with 'onNonMatchingHeader' in rule options.
gotcha The rule will error if no matching header is found, even if the file is empty.
fix Add an allowEmptyFiles option or ensure all files have at least a header.
gotcha The '--fix' mode only prepends the header; it does not remove existing non-matching headers unless onNonMatchingHeader is set to 'replace'.
fix Set onNonMatchingHeader: 'replace' to replace existing headers.
deprecated The option 'nonMatchingTolerance' is deprecated and may be removed in a future version.
fix Use 'onNonMatchingHeader' with 'report' or 'prepend' instead.
npm install eslint-plugin-notice
yarn add eslint-plugin-notice
pnpm add eslint-plugin-notice

Configures the plugin to enforce a copyright notice header using a template with placeholders for year and author.

// .eslintrc.js
module.exports = {
  plugins: ['notice'],
  rules: {
    'notice/notice': ['error', {
      template: '/* Copyright (c) {{year}} {{author}} */\n',
      authors: ['John Doe'],
      onNonMatchingHeader: 'prepend', // or 'replace', 'report'
      var: { year: new Date().getFullYear().toString() }
    }]
  }
};