UNPKG

3.88 kBMarkdownView Raw
1# eslint-plugin-jasmine
2
3[![Build Status][travis-image]][travis-url]
4[![npm version][npm-image]][npm-url]
5[![License][license-image]][license-url]
6
7[travis-url]: https://travis-ci.org/tlvince/eslint-plugin-jasmine
8[travis-image]: https://img.shields.io/travis/tlvince/eslint-plugin-jasmine.svg
9[npm-url]: https://www.npmjs.com/package/eslint-plugin-jasmine
10[npm-image]: https://img.shields.io/npm/v/eslint-plugin-jasmine.svg
11[license-url]: https://opensource.org/licenses/MIT
12[license-image]: https://img.shields.io/npm/l/eslint-plugin-jasmine.svg
13
14> ESLint rules for Jasmine
15
16## Usage
17
181. Install `eslint-plugin-jasmine` as a dev-dependency:
19
20 ```shell
21 npm install --save-dev eslint-plugin-jasmine
22 ```
23
242. Enable the plugin by adding it to your `.eslintrc`:
25
26 ```yaml
27 plugins:
28 - jasmine
29 ```
30
31ESLint itself provides a [Jasmine environment][env] for Jasmine's global
32variables. It's therefore recommended to also enable it in your `.eslintrc`:
33
34```yaml
35plugins:
36 - jasmine
37env:
38 jasmine: true
39```
40
41By default, no rules are enabled. See the next section for more.
42
43[env]: http://eslint.org/docs/user-guide/configuring#specifying-environments
44
45## Configuration
46
47This plugin exports a `recommended` configuration that enforces good practices.
48
49To enable this configuration, use the `extends` property in your `.eslintrc`
50config file:
51
52```yaml
53plugins:
54 - jasmine
55env:
56 jasmine: true
57extends: 'plugin:jasmine/recommended'
58```
59
60See the [ESLint config docs][] for more information about extending
61configuration files.
62
63[eslint config docs]: http://eslint.org/docs/user-guide/configuring#extending-configuration-files
64
65### Rules
66
67Rule | Recommended | Options
68---- | ----------- | -------
69[named-spy][] | 0 |
70[no-focused-tests][] | 2 |
71[no-disabled-tests][] | 1 |
72[no-suite-dupes][] | 1, `'block'` | `['block', 'branch']`
73[no-spec-dupes][] | 1, `'block'` | `['block', 'branch']`
74[missing-expect][] | 0, `'expect()'` | expectation function names
75[no-suite-callback-args][] | 2 |
76[valid-expect][] | 1 |
77[no-assign-spyon][] | 0 |
78[no-unsafe-spy][] | 1 |
79[no-global-setup][] | 2 |
80[no-expect-in-setup-teardown][] | 1, `'expect()'` | expectation function names
81
82For example, using the recommended configuration, the `no-focused-tests` rule
83is enabled and will cause ESLint to throw an error (with an exit code of `1`)
84when triggered.
85
86You may customise each rule by adding a value in your `.eslintrc` `rules`
87property:
88
89```yaml
90plugins:
91 - jasmine
92env:
93 jasmine: true
94rules:
95 jasmine/no-focused-tests: 0
96 jasmine/no-suite-dupes:
97 - 2
98 - branch
99```
100
101See [configuring rules][] for more information.
102
103[named-spy]: docs/rules/named-spy.md
104[no-focused-tests]: docs/rules/no-focused-tests.md
105[no-disabled-tests]: docs/rules/no-disabled-tests.md
106[no-suite-dupes]: docs/rules/no-suite-dupes.md
107[no-spec-dupes]: docs/rules/no-spec-dupes.md
108[missing-expect]: docs/rules/missing-expect.md
109[no-suite-callback-args]: docs/rules/no-suite-callback-args.md
110[valid-expect]: docs/rules/valid-expect.md
111[no-assign-spyon]: docs/rules/no-assign-spyon.md
112[no-unsafe-spy]: docs/rules/no-unsafe-spy.md
113[no-global-setup]: docs/rules/no-global-setup.md
114[no-expect-in-setup-teardown]: docs/rules/no-expect-in-setup-teardown.md
115
116[configuring rules]: http://eslint.org/docs/user-guide/configuring#configuring-rules
117
118## Author
119
120© 2016 Tom Vincent <git@tlvince.com> and [contributors][].
121
122[contributors]: https://github.com/tlvince/eslint-plugin-jasmine/graphs/contributors
123
124## License
125
126Released under the [MIT license](http://tlvince.mit-license.org).