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

@shadowdara/linguist-js

v1.0.0

Published

A Node.js reimplementation of github/linguist with full .gitattributes support (linguist-language, linguist-vendored, linguist-documentation, linguist-generated, linguist-detectable, linguist-ignore).

Readme

linguist-js

A standalone Node.js tool that computes a repository's language statistics like github/linguist and respects all relevant .gitattributes directives:

  • linguist-language=<Name> — force the language for matching files
  • linguist-vendored[=true|false] — mark/unmark as vendored code
  • linguist-documentation[=true|false] — mark/unmark as documentation
  • linguist-generated[=true|false] — mark/unmark as generated
  • linguist-detectable[=true|false] — override the default visibility in the statistics
  • linguist-ignore — ignore the file completely (also in --files)

Nested .gitattributes files are handled correctly: per path, the nearest .gitattributes file always wins for an attribute (same behavior as Git itself); within a file, the last matching line wins.

Usage

node linguist.js [Path]              # Print language statistics (default: current directory)
node linguist.js [Path] --files      # Additionally list each file with its detected language
node linguist.js [Path] --breakdown  # Also print a per-language file list
node linguist.js [Path] --json       # Output as JSON
node linguist.js [Path] --all        # Without git: scan the entire directory tree (instead of `git ls-files`)

By default, git ls-files is used, so .gitignore is respected automatically (untracked/ignored files do not appear there). Outside a Git repository or with --all, the complete file tree is scanned instead (only .git/ is excluded).

Example

With a .gitattributes like:

samfile linguist-language=Shell
go.sum linguist-language=go
docker-compose.yml linguist-language=Dockerfile
/cmd/findergen/frontend/** linguist-vendored
/.obsidian/** linguist-vendored
*.json linguist-detectable=true

linguist.js detects:

  • samfile as Shell, even though it has no extension
  • go.sum as go (override), regardless of the default detection
  • docker-compose.yml as Dockerfile instead of YAML
  • everything under /cmd/findergen/frontend/ and /.obsidian/ is excluded from the statistics (vendored)
  • *.json files are included in the statistics (unlike the default)

Language database (languages.json)

Contains a hand-picked subset (~90 entries) of Linguist's real languages.yml: type (programming/markup/data/prose), extensions, filenames, interpreters (for shebang detection) and optional detectable (default: true for programming/markup, false for data/prose — analogous to Linguist, see e.g. JSON/YAML/Markdown).

You can extend the file freely to add more languages, extensions or filenames.

Known limitations (deliberate simplifications)

Compared to the real Ruby gem github-linguist:

  • No heuristics/Bayes classifier for ambiguous extensions (e.g. .h C vs. C++, .m Objective-C vs. MATLAB) — the first match from languages.json is always taken. For such cases, simply set linguist-language in .gitattributes.
  • Binary detection is a simple null-byte scan of the first 8 KB (no charlock_holmes/encoding detection).
  • Vendor/documentation/generated defaults are a compact subset of the real vendor.yml/documentation.yml rules — the most important cases (node_modules, dist, build, vendor, lockfiles, README/LICENSE/CHANGELOG) are covered, but not complete.
  • With an explicit linguist-language override, the file is by default automatically treated as detectable (unless linguist-vendored/-documentation/-generated/-detectable=false is also explicitly set) — this matches the common practical purpose of such an override (e.g. go.sum linguist-language=go, so that it shows up in the statistics).

For the absolute reference implementation, the official github-linguist gem remains authoritative — this tool is intended for Node-only environments/CI without Ruby.