ESLint rules for Jasmine
-
Install
eslint-plugin-jasmine
as a dev-dependency:npm install --save-dev eslint-plugin-jasmine
-
Enable the plugin by adding it to your
.eslintrc
:plugins: - jasmine
ESLint itself provides a Jasmine environment for Jasmine's global
variables. It's therefore recommended to also enable it in your .eslintrc
:
plugins:
- jasmine
env:
jasmine: true
By default, no rules are enabled. See the next section for more.
This plugin exports a recommended
configuration that enforces good practices.
To enable this configuration, use the extends
property in your .eslintrc
config file:
plugins:
- jasmine
env:
jasmine: true
extends: 'plugin:jasmine/recommended'
See the ESLint config docs for more information about extending configuration files.
Rule | Recommended | Options |
---|---|---|
named-spy | 0 | |
no-focused-tests | 2 | |
no-disabled-tests | 1 | |
no-suite-dupes | 1, 'block' |
['block', 'branch'] |
no-spec-dupes | 1, 'block' |
['block', 'branch'] |
missing-expect | 0, 'expect()' |
expectation function names |
no-suite-callback-args | 2 | |
valid-expect | 1 | |
no-assign-spyon | 0 | |
no-unsafe-spy | 1 |
For example, using the recommended configuration, the no-focused-tests
rule
is enabled and will cause ESLint to throw an error (with an exit code of 1
)
when triggered.
You may customise each rule by adding a value in your .eslintrc
rules
property:
plugins:
- jasmine
env:
jasmine: true
rules:
jasmine/no-focused-tests: 0
jasmine/no-suite-dupes:
- 2
- branch
See configuring rules for more information.
© 2016 Tom Vincent git@tlvince.com and contributors.
Released under the MIT license.