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-dotignore

v1.0.0

Published

Lint, sort, group, and fix .gitignore files — an ESLint language plugin with a spec-exact parser.

Readme

eslint-plugin-dotignore

CI npm version License: MIT

Lint, sort, group, and fix .gitignore files with ESLint.

Git never complains about a .gitignore — it silently ignores what it can't parse, silently skips negations that can never apply, and happily tolerates duplicates, dead patterns, and trailing whitespace that changes nothing. This plugin makes all of that visible, and fixes most of it automatically.

Highlights

  • Real parsing, not regex guessing — a dedicated gitignore language for ESLint's language API, with a proper AST, exact ranges, and spec-faithful semantics.
  • Finds dead lines — negations Git can never apply, patterns already covered by earlier ones, ** that silently degrades to *.
  • Keeps files tidy — alphabetical sorting and folder/file grouping with configurable headings, done without ever changing what Git actually ignores.
  • Safe autofixes — every fix is semantics-preserving; when a reorder could change behavior, the rule declines instead of guessing.
  • A reusable parser — import eslint-plugin-dotignore/parser and get the AST with zero ESLint baggage.

Installation

# pnpm
pnpm add -D eslint eslint-plugin-dotignore

# npm
npm install --save-dev eslint eslint-plugin-dotignore

# yarn
yarn add --dev eslint eslint-plugin-dotignore

Requires ESLint ≥ 9.7.0 (flat config) and Node ≥ 22.18.

Usage

// eslint.config.js
import dotignore from "eslint-plugin-dotignore";

export default [dotignore.configs.recommended];

That's it — .gitignore files are now linted. Prefer full control? Wire it manually:

import dotignore from "eslint-plugin-dotignore";

export default [
  {
    files: ["**/.gitignore"],
    plugins: { dotignore },
    language: "dotignore/gitignore",
    rules: {
      "dotignore/sort-patterns": "warn",
      "dotignore/group-patterns": "warn",
    },
  },
];

Rules

💼 Configurations enabled in.
⚠️ Configurations set to warn in.
✅ Set in the recommended configuration.
🔒 Set in the strict configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.

| Name                        | Description | 💼 | ⚠️ | 🔧 | 💡 | | :----------------------------------------------------------------------- | :-------------------------------------------------------------------------- | :---- | :-- | :-- | :-- | | comment-spacing | enforce consistent spacing after '#' in comments | 🔒 | ✅ | 🔧 | | | group-patterns | group directory-only patterns and file patterns under configurable headings | 🔒 | | 🔧 | | | leading-slash-style | enforce a consistent leading-slash style for anchored patterns | 🔒 | ✅ | 🔧 | | | max-consecutive-blank-lines | limit consecutive blank lines | 🔒 | ✅ | 🔧 | | | no-backslash-path | disallow backslash as a path separator | ✅ 🔒 | | | 💡 | | no-duplicate-pattern | disallow duplicate and equivalent patterns | ✅ 🔒 | | 🔧 | | | no-empty-group | disallow group headings with no patterns under it | 🔒 | ✅ | 🔧 | | | no-empty-path-segment | disallow empty path segments | ✅ 🔒 | | | 💡 | | no-invalid-syntax | disallow patterns that violate the gitignore specification | ✅ 🔒 | | | | | no-misplaced-globstar | disallow '**' in positions where it loses its special meaning | ✅ 🔒 | | 🔧 | | | no-redundant-pattern | disallow patterns already covered by another pattern | ✅ 🔒 | | 🔧 | | | no-trailing-whitespace | disallow unescaped trailing whitespace | 🔒 | ✅ | 🔧 | | | no-unreachable-negation | disallow negations that Git can never apply | ✅ 🔒 | | | 💡 | | require-dir-slash | require a trailing slash on patterns that match existing directories | 🔒 | | 🔧 | | | sort-patterns | enforce alphabetical ordering of patterns | 🔒 | | 🔧 | |

Presets

  • configs.recommended — spec violations and dead patterns as errors, whitespace and style hygiene as warnings. Reordering rules (sort-patterns, group-patterns) and the filesystem-aware require-dir-slash stay off — enable them deliberately.
  • configs.strict — every rule as an error.

Using alongside Prettier

Formatter rules like prettier/prettier (from eslint-plugin-prettier) apply to every file their config matches — including .gitignore, which Prettier cannot parse. If you use such a setup, scope it to the files it understands:

import prettierRecommended from "eslint-plugin-prettier/recommended";

export default [
  { ...prettierRecommended, files: ["**/*.{js,ts,jsx,tsx}"] },
  dotignore.configs.recommended,
];

This applies to any rule that assumes JavaScript syntax — the same scoping every non-JavaScript ESLint language (JSON, Markdown, CSS) calls for.

The parser, standalone

The gitignore parser is exported on its own, free of any ESLint dependency:

import { parse } from "eslint-plugin-dotignore/parser";

const ast = parse("node_modules/\n!keep.txt\n");

Text in, AST out — every line classified as Pattern, Comment, or BlankLine, with exact ranges and locations. Useful for codemods, editor tooling, or anything else that needs to understand a .gitignore without string surgery.

License

MIT © Erdem Bircan