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

@putout/plugin-package-json

v8.3.0

Published

🐊Putout plugin for package.json

Downloads

64,599

Readme

@putout/plugin-package-json NPM version

🐊Putout plugin helps to automate fixing package.json.

Install

npm i @putout/plugin-package-json -D

Rules

Config

{
    "rules": {
        "package-json/add-type": "on",
        "package-json/apply-https-to-repository-url": "on",
        "package-json/remove-nyc": "on",
        "package-json/remove-commit-type": "on",
        "package-json/remove-exports-with-missing-files": "off",
        "package-json/find-file": "off"
    }
}

add-type

Add type field to package.json:

{
    "name": "hello",
    "version": "1.0.0",
+   "type": "commonjs"
}

apply-https-to-repository-url

The git:// protocol for GitHub repos should not be used due security concerns.

Checkout in 🐊Putout Editor.

{
  "repository": {
    "type": "git",
-   "url": "git://github.com/coderaiser/putout.git"
+   "url": "git+https://github.com/coderaiser/putout.git"
  }

remove-nyc

  • additional fields in package.json produces more traffic then users of your package really need;
  • c8 uses same config name and format so transition between tools will be much easier;

❌ Example of incorrect code

nyc section in package.json:

{
    "nyc": {
        "check-coverage": "on",
        "all": "on",
        "exclude": [
            "**/*.spec.js",
            "**/fixture",
            "test",
            ".*.js"
        ],
        "branches": 100,
        "lines": 100,
        "functions": 100,
        "statements": 100
    }
}

✅ Example of correct code

File .nycrc.json:

{
    "check-coverage": "on",
    "all": "on",
    "exclude": [
        "**/*.spec.js",
        "**/fixture",
        "test",
        ".*.js"
    ],
    "branches": 100,
    "lines": 100,
    "functions": 100,
    "statements": 100
}

remove-commit-type

Since 🎁Wisdom v14 commitType set to colon be default, so it can be dropped from package.json if it's value not paren: Check out in 🐊Putout Editor.

{
    "name": "hello",
    "version": "1.0.0",
    "commitType": "colon"
}

find-file

Find package.json inside of .filesystem.json and applies all other package-json rules. Checkout in 🐊Putout Editor.

{
    "name": "hello",
    "version": "1.0.0",
+   "type": "commonjs"
}

remove-exports-with-missing-files

Find package.json inside of .filesystem.json and removes exports with missing files.

Checkout in 🐊Putout Editor:

__putout_processor_filesystem([
    "/",
    ["/package.json", `{
        "exports": {
            "./parse-options": "./lib/parse-options/index.js",
-            "./loader": "./lib/loader.mjs"
        }
    }`],
    "/lib/",
    "/lib/parse-options/",
    ["/lib/parse-options/index.js", "export const a = 5"],
]);

License

MIT