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-comment-position

v0.4.3

Published

[![CI](https://github.com/sedlukha/eslint-plugin-comment-position/actions/workflows/ci.yml/badge.svg)](https://github.com/sedlukha/eslint-plugin-comment-position/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/sedlukha/eslint-plugin-comment-po

Readme

eslint-plugin-comment-position

CI codecov npm version npm downloads license

Enforce a consistent comment position in your JavaScript/TypeScript code — either above the code or beside it (inline). Auto-fixable.

Why?

ESLint does not enforce consistent comment placement. This plugin ensures comments are always placed either:

  • above the code
  • or inline with it

This improves readability, diff clarity, and team consistency.

❌ Before

const foo = 1; // explanation

✅ After (position: "above")

// explanation
const foo = 1;

Installation

npm install -D eslint-plugin-comment-position

Supports ESLint 9 and 10.

Usage

// eslint.config.js
import commentPosition from "eslint-plugin-comment-position";

export default [
  {
    plugins: { "comment-position": commentPosition },
    rules: {
      // Enforce all comments above the code:
      "comment-position/position": ["error", { position: "above" }],

      // — or — enforce all comments beside the code (inline):
      // "comment-position/position": ["error", { position: "beside" }],
    },
  },
];

Built-in configs (shorthand)

import commentPosition from "eslint-plugin-comment-position";

export default [
  // position: "above"  (recommended default)
  ...commentPosition.configs.recommended,

  // — or — position: "beside"
  // ...commentPosition.configs["recommended-beside"],
];

Rules

| Rule | Description | Fixable | | --------------------------- | ----------------------------------------------- | ------- | | comment-position/position | Enforce comment position (above or beside code) | ✅ |

comment-position/position

Enforces that all line (//) and single-line block (/* */) comments are placed either above or beside the code they describe.

Multi-line block comments (/* \n ... \n */) are intentionally ignored — they are typically used for JSDoc or file headers. JSX expression comments ({/* ... */}) are also always ignored — they use required wrapper syntax that cannot be reformatted.

Unlike the built-in no-inline-comments and line-comment-position rules (and @stylistic/line-comment-position), this rule supports --fix and will automatically move comments to the correct position.

Options

| Option | Type | Required | Default | Description | | ---------------------------- | ----------------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------- | | position | "above" | "beside" | yes | — | Where comments must be placed | | ignorePattern | string | no | — | Regex string. Comments matching this pattern are skipped | | applyDefaultIgnorePatterns | boolean | no | true | When true, ESLint directive comments (eslint-disable, eslint-disable-line, etc.) are always ignored |

position: "above"

Examples of 👎 incorrect code for these options:

const x = 1; // this is a comment
//            ^^^^^^^^^^^^^^^^^^^^ move above

/* block comment */ const y = 2;
// ^^^^^^^^^^^^^^^^ move to its own line above

Examples of 👍 correct code for these options:

// this is a comment
const x = 1;

/* block comment */
const y = 2;

position: "beside"

Examples of 👎 incorrect code for these options:

// this is a comment
const x = 1;
// ^^^^^^^^^^^^^^^^^ move beside the code below

/* block comment */ const y = 2;
// ^^^^^^^^^^^^^^^^ move to end of line

Examples of 👍 correct code for these options:

const x = 1; // this is a comment
const y = 2; /* block comment */

Example with options

// eslint.config.js
export default [
  {
    plugins: { "comment-position": commentPosition },
    rules: {
      "comment-position/position": [
        "error",
        {
          position: "above",
          ignorePattern: "^\\s*TODO", // ignore TODO comments
          applyDefaultIgnorePatterns: true, // ignore eslint directives (default)
        },
      ],
    },
  },
];

See also

License

MIT