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

counsel-rule

v0.5.2

Published

defines a piece of _counselling_ to apply to a project. how punny.

Downloads

41

Readme

counsel-rule

defines a piece of counselling to apply to a project. how punny.

this package is the base class counsel rule.

how do i make my own rule?

  • rules do not need to extend Rule, exported by counsel-rule.
  • a rule is any old POJO with an apply and/or check method!
    • the apply method should do something interesting to your project. apply receives the counsel instance, which provides some very useful utilities to expose the target project. see the example below for more.

create a rule

here's a fully flushed example:

'use strict'

const Rule = require('counsel-rule')

module.exports = new Rule({
  // dependencies: ['async'], // <== installs any package (at the end of the rule apply chain)
  // devDependencies: ['tape', 'pify'], // <== installs any package (at the end of the rule apply chain)
  apply: function(counsel) {
    // do something interesting

    // some helpful refs (more at https://cdaringe.github.io/counsel/counsel/)

    // counsel.targetProjectPackageJson
    // ^modify the target package.json as you see fit! we will detect changes and write it

    // counsel.config
    // ^ get declarations made towards counsel in the target package's package.json

    // counsel.project.xzy
    // ^ a handful of things
  },
  check: function(counsel) {
    // add assertions that your rule is applied adequately.  optional, but encouraged
  }
})
  • apply it (per counsel docs)

how to override a rule?

dependency overrides

// package.json
{
  "counsel": { // or your dev-tool's config key
    "overrides": {
      "your-rule-name": { // make sure to add a rule name to your rules!
        "dependencies": { // add or remove deps from a rule's defaults
          "add": ["x", "y", "z"], // or "plus"
          "substract": "e" // or "minus". accepts string|string[]
        },
        "devDependencies": ["m", "n"] // squashes default devDependencies
      },
      "skip-this-rule": null // `null` skips rules altogether
    }
  }
}