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 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-simple-header

v1.2.1

Published

Simple to use license header plugin for ESLint

Downloads

7,265

Readme

eslint-plugin-simple-header

Simple to use license header plugin for ESLint.

Installation

Add eslint-plugin-simple-header as a dev dependency using your package manager:

$ pnpm add -D eslint-plugin-simple-header
# or yarn, npm etc

Usage

Given the following configuration:

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: GPL-3.0-or-later",
        ],
        templates: { author: [".*", "rini"] },
      }]
    },
  },
]

The rule will match a header like this:

/*
 * Copyright (c) 1970 Linus Torvalds
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

And when running auto-fix, will insert a header like so:

/*
 * Copyright (c) 2023 Rini
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

(Where 2023 is the current year, if you are from the future)

text may be an array of lines, or an entire string. It’s also possible to give an array of paths to files. In both cases, they can include comment syntax and won’t be autoformatted (i.e. prefixed with *s).

Inside the header’s text {template} syntax can be used, which correlates to the template key. The first value is a regex used to match the header, and the second is a default value. By default, year matches \d{4} and defaults the current year.

A few other options include:

  • newlines specifies exactly how many lines should be after the header, and defaults to 1. If the file is empty otherwise, no newlines are added.
  • syntax specifies the comment syntax, defaults to ["/*", "*/"]. It may also be a string, for single-line comment blocks (e.g. //)
  • decor specifies how the comment is formatted with a tuple of start, indent and end. When syntax is a block comment, this defaults to ["\n", " * ", "\n "], and defaults to " " otherwise.
  • linebreak specifies the line ending to expect on files: "unix" for LF, "windows" for CRLF. By default it will auto-detect from the file.