eslint-plugin-tape
v1.1.0
Published
ESLint rules for tape
Downloads
386
Maintainers
Readme
eslint-plugin-tape
ESLint rules for tape
This ESLint plugin is a copy of the great eslint-plugin-ava adapting the rules to work for tape tests and removing AVA specific rules.
Install
$ npm install --save-dev eslint eslint-plugin-tape
Usage
Configure it in your package.json
or eslintrc.*
file as described in ESLint user guide.
{
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"plugins": [
"tape"
],
"rules": {
"tape/assertion-message": ["off", "always"],
"tape/max-asserts": ["off", 5],
"tape/no-identical-title": "error",
"tape/no-ignored-test-files": "error",
"tape/no-only-test": "error",
"tape/no-skip-assert": "error",
"tape/no-skip-test": "error",
"tape/no-statement-after-end": "error",
"tape/no-unknown-modifiers": "error",
"tape/test-ended": "error",
"tape/test-title": ["error", "if-multiple"],
"tape/use-t-well": "error",
"tape/use-t": "error",
"tape/use-test": "error",
}
}
Rules
The rules will only activate in test files.
- assertion-message - Enforce or disallow assertion messages.
- max-asserts - Limit the number of assertions in a test.
- no-identical-title - Ensure no tests have the same title.
- no-ignored-test-files - Ensure no tests are written in ignored files.
- no-only-test - Ensure no
test.only()
are present. - no-skip-assert - Ensure no assertions are skipped.
- no-skip-test - Ensure no tests are skipped.
- no-statement-after-end - Ensure
t.end()
is the last statement executed. - no-unknown-modifiers - Prevent the use of unknown test modifiers.
- test-ended - Ensure callback tests are explicitly ended.
- test-title - Ensure tests have a title.
- use-t-well - Prevent the incorrect use of
t
. - use-t - Ensure test functions use
t
as their parameter. - use-test - Ensure that tape is imported with
test
as the variable name.
Recommended config
This plugin exports a recommended
config that enforces good practices.
Enable it in your package.json
with the extends
option:
{
"name": "my-awesome-project",
"eslintConfig": {
"plugins": [
"tape"
],
"extends": "plugin:tape/recommended"
}
}
See the ESLint docs for more information about extending config files.
Note: This config will also enable the correct parser options and environment.
Credit
- Sindre Sorhus & AVA team for the fantastic work with eslint-plugin-ava