Skip to content

Disallow the use of describe.only() and it.only()

License

Notifications You must be signed in to change notification settings

funbox/eslint-plugin-no-only-tests

Folders and files

NameName
Last commit message
Last commit date
May 16, 2023
Feb 14, 2022
Feb 14, 2022
Jul 6, 2018
Feb 14, 2022
Jul 6, 2018
May 19, 2023
Jul 6, 2020
May 19, 2023
Jul 9, 2020
Jul 9, 2020
May 22, 2023
May 22, 2023

Repository files navigation

@funboxteam/eslint-plugin-no-only-tests

npm

Disallow the use of describe.only() and it.only().

По-русски

Rationale

When developers fix tests they may make the process easier by filtering tests using method only on it & describe.

However, such filters should not be in the repo when the project is running on CI. So, we add this rule to our ESLint config to check the existence of only in the tests files. And we run linter using precommit-hook, which make it possible to prevent committing when only does exist in the code.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install the plugin:

$ npm install @funboxteam/eslint-plugin-no-only-tests --save-dev

Usage

Add @funboxteam/eslint-plugin-no-only-tests to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": [
    "@funboxteam/no-only-tests"
  ]
}

Then configure the rule under the rules section.

{
  "rules": {
    "@funboxteam/no-only-tests/no-only": 2
  }
}

Sponsored by FunBox