eslint-plugin-chai-expect
ESLint plugin that checks for common chai.js expect() mistakes
Requirements
- Node.js 6 or above
- ESLint 4.x or 5.x or 6.x
Installation
npm install --save-dev eslint-plugin-chai-expect
Configuration
Add a plugins section and specify chai-expect as a plugin:
Enable the rules that you would like to use:
Or, if you just want the above defaults, you can avoid all of the above and just extend the config:
Rules
no-inner-compare- Prevent using comparisons in theexpect()argumentno-inner-literal- Prevent using literals in theexpect()argument (undefined,null,NaN,(+|-)Infinity,this, booleans, numbers, strings, and BigInt or regex literals)missing-assertion- Prevent callingexpect(...)without an assertion like.to.be.okterminating-properties- Prevent callingto.be.okand other assertion properties as functions
Additional configuration
terminating-properties rule
A number of extensions 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:
License
eslint-plugin-chai-expect is licensed under the MIT License.