# counsel-rule

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

Latest version **0.5.2** (published 2017-09-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install counsel-rule
pnpm add counsel-rule
yarn add counsel-rule
bun add counsel-rule
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.2 |
| Published | 2017-09-28 |
| First published | 2016-10-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | cdaringe |
| Maintainers | cdaringe |

## Links

- npm: https://www.npmjs.com/package/counsel-rule
- Repository: https://github.com/cdaringe/counsel
- Homepage: https://cdaringe.github.io/counsel/
- Issues: https://github.com/cdaringe/counsel/issues
- npm.io page: https://npm.io/package/counsel-rule

## Recent versions

- 0.5.2 (latest) — 2017-09-28
- 0.5.1 — 2017-09-22
- 0.5.0 — 2017-09-22
- 0.4.1 — 2017-08-14
- 0.4.0 — 2017-08-14
- 0.3.1-0 — 2017-08-14
- 0.3.0 — 2017-08-08
- 0.2.0 — 2017-08-07
- 0.1.4 — 2017-03-27
- 0.1.3 — 2017-03-27
- 0.1.1 — 2017-03-23
- 0.0.29 — 2017-01-17
- 0.0.28 — 2017-01-12
- 0.0.26 — 2017-01-09
- 0.0.23 — 2016-12-01
- … 11 more at https://npm.io/package/counsel-rule/versions

## 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](https://en.wikipedia.org/wiki/Plain_Old_Java_Object) 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:

```js
'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

```js
// 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
    }
  }
}
```

---
_Source: https://npm.io/package/counsel-rule · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
