Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

eslint-plugin-chai-expect

2.0.1 • Public • Published

eslint-plugin-chai-expect

Build Status

ESLint plugin that checks for common chai.js expect() mistakes

Requirements

  • Node.js 6 or above
  • ESLint 4.x or 5.x

Installation

npm install --save-dev eslint-plugin-chai-expect

Configuration

Add a plugins section and specify chai-expect as a plugin:

{
  "plugins": [
    "chai-expect"
  ]
}

Enable the rules that you would like to use:

{
  "rules": {
    "chai-expect/missing-assertion": 2,
    "chai-expect/terminating-properties": 1
  }
}

Rules

  • no-inner-compare - Prevent using comparisons in the expect() argument
  • missing-assertion - Prevent calling expect(...) without an assertion like .to.be.ok
  • terminating-properties - Prevent calling to.be.ok and other assertion properties as functions

Additional configuration

terminating-properties rule

A number of extenstions to chai add additional terminating properties. For example chai-http adds:

  • headers
  • html
  • ip
  • json
  • redirect
  • text

The terminating-properties rule can be configured to ensure these (or other) additional properties are not used as functions:

{
  "rules": {
    "chai-expect/terminating-properties": ["error", {
      "properties": ["headers", "html", "ip", "json", "redirect", "test"]
    }]
  }
}

License

eslint-plugin-chai-expect is licensed under the MIT License.

install

npm i eslint-plugin-chai-expect

Downloadsweekly downloads

26,248

version

2.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability