All Projects → ihordiachenko → eslint-plugin-chai-friendly

ihordiachenko / eslint-plugin-chai-friendly

Licence: MIT license
Makes eslint friendly towards Chai.js 'expect' and 'should' statements.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to eslint-plugin-chai-friendly

eslint-plugin-import
ESLint plugin with rules that help validate proper imports.
Stars: ✭ 4,290 (+8655.1%)
Mutual labels:  linting, eslint-plugin
Cfn nag
Linting tool for CloudFormation templates
Stars: ✭ 808 (+1548.98%)
Mutual labels:  unit-testing, linting
Eslint Plugin Import
ESLint plugin with rules that help validate proper imports.
Stars: ✭ 3,722 (+7495.92%)
Mutual labels:  linting, eslint-plugin
Redux Actions Assertions
Simplify testing of redux action and async action creators
Stars: ✭ 177 (+261.22%)
Mutual labels:  unit-testing, chai
Eslint Plugin Ember
An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
Stars: ✭ 240 (+389.8%)
Mutual labels:  linting, eslint-plugin
chai-exclude
Exclude keys to compare from a deep equal operation with chai expect or assert.
Stars: ✭ 33 (-32.65%)
Mutual labels:  unit-testing, chai
tead
Lighting the way to simpler testing
Stars: ✭ 55 (+12.24%)
Mutual labels:  unit-testing
editorconfig-checker.javascript
A tool to verify that your files are in harmony with your .editorconfig
Stars: ✭ 59 (+20.41%)
Mutual labels:  linting
utest
Lightweight unit testing framework for C/C++ projects. Suitable for embedded devices.
Stars: ✭ 18 (-63.27%)
Mutual labels:  unit-testing
KrazyKotlin
A collection of useful Kotlin Extension
Stars: ✭ 75 (+53.06%)
Mutual labels:  unit-testing
seed-barista
☕️ Barista: CSS unit testing with Javascript
Stars: ✭ 24 (-51.02%)
Mutual labels:  unit-testing
chai-subset
"containSubset" object properties matcher for Chai
Stars: ✭ 82 (+67.35%)
Mutual labels:  chai
stubthat
Stubbing framework for R
Stars: ✭ 17 (-65.31%)
Mutual labels:  unit-testing
eslint-plugin-roku
ESLint plugin to parse and lint BrightScript files
Stars: ✭ 44 (-10.2%)
Mutual labels:  eslint-plugin
react-testing-mocha-chai-enzyme
A solid test setup for React components with Mocha, Chai, Sinon, Enzyme in a Webpack/Babel application.
Stars: ✭ 48 (-2.04%)
Mutual labels:  chai
eslint-plugin-yml
This ESLint plugin provides linting rules for YAML.
Stars: ✭ 40 (-18.37%)
Mutual labels:  eslint-plugin
Golite
Add essential language support for the Go language to Sublime Text 3.
Stars: ✭ 14 (-71.43%)
Mutual labels:  linting
js-stack-from-scratch
🌺 Russian translation of "JavaScript Stack from Scratch" from the React-Theming developers https://github.com/sm-react/react-theming
Stars: ✭ 394 (+704.08%)
Mutual labels:  chai
emacs-jest
A package to run jest inside emacs
Stars: ✭ 74 (+51.02%)
Mutual labels:  unit-testing
vim-UT
Unit Testing plugin for Vim
Stars: ✭ 18 (-63.27%)
Mutual labels:  unit-testing

eslint-plugin-chai-friendly

npm npm

This plugin overrides no-unused-expressions to make it friendly towards chai expect and should statements.

// this
expect(foo).to.be.true;
foo.should.be.true;

// instead of this
expect(foo).to.be.true; // eslint-disable-line no-unused-expressions
foo.should.be.true; // eslint-disable-line no-unused-expressions

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-chai-friendly:

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

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-chai-friendly globally.

Usage

Add chai-friendly to the plugins section of your .eslintrc.* configuration file. You can omit the eslint-plugin- prefix:

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

Then disable original no-unused-expressions rule and configure chai-friendly replacement under the rules section.

{
    "rules": {
        "no-unused-expressions": 0,
        "chai-friendly/no-unused-expressions": 2
    }
}

If you don't need to tweak the above rule settings, you can instead just add the following to your config file's extends and the above will be applied automatically:

{
  "extends": ["plugin:chai-friendly/recommended"]
}

Options

This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

  • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
  • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
  • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).
  • enforceForJSX set to true will flag unused JSX element expressions (Default: false).

These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

More info in the original rule's docs.

Supported Rules

  • chai-friendly/no-unused-expressions
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].