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 |
|
18 | 1. Install `eslint-plugin-jasmine` as a dev-dependency:
|
19 |
|
20 | ```shell
|
21 | npm install --save-dev eslint-plugin-jasmine
|
22 | ```
|
23 |
|
24 | 2. Enable the plugin by adding it to your `.eslintrc`:
|
25 |
|
26 | ```yaml
|
27 | plugins:
|
28 | - jasmine
|
29 | ```
|
30 |
|
31 | ESLint itself provides a [Jasmine environment][env] for Jasmine's global
|
32 | variables. It's therefore recommended to also enable it in your `.eslintrc`:
|
33 |
|
34 | ```yaml
|
35 | plugins:
|
36 | - jasmine
|
37 | env:
|
38 | jasmine: true
|
39 | ```
|
40 |
|
41 | By 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 |
|
47 | This plugin exports a `recommended` configuration that enforces good practices.
|
48 |
|
49 | To enable this configuration, use the `extends` property in your `.eslintrc`
|
50 | config file:
|
51 |
|
52 | ```yaml
|
53 | plugins:
|
54 | - jasmine
|
55 | env:
|
56 | jasmine: true
|
57 | extends: 'plugin:jasmine/recommended'
|
58 | ```
|
59 |
|
60 | See the [ESLint config docs][] for more information about extending
|
61 | configuration files.
|
62 |
|
63 | [eslint config docs]: http://eslint.org/docs/user-guide/configuring#extending-configuration-files
|
64 |
|
65 | ### Rules
|
66 |
|
67 | Rule | 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 |
|
81 | For example, using the recommended configuration, the `no-focused-tests` rule
|
82 | is enabled and will cause ESLint to throw an error (with an exit code of `1`)
|
83 | when triggered.
|
84 |
|
85 | You may customise each rule by adding a value in your `.eslintrc` `rules`
|
86 | property:
|
87 |
|
88 | ```yaml
|
89 | plugins:
|
90 | - jasmine
|
91 | env:
|
92 | jasmine: true
|
93 | rules:
|
94 | jasmine/no-focused-tests: 0
|
95 | jasmine/no-suite-dupes:
|
96 | - 2
|
97 | - branch
|
98 | ```
|
99 |
|
100 | See [configuring rules][] for more information.
|
101 |
|
102 | [named-spy]: docs/rules/named-spy.md
|
103 | [no-focused-tests]: docs/rules/no-focused-tests.md
|
104 | [no-disabled-tests]: docs/rules/no-disabled-tests.md
|
105 | [no-suite-dupes]: docs/rules/no-suite-dupes.md
|
106 | [no-spec-dupes]: docs/rules/no-spec-dupes.md
|
107 | [missing-expect]: docs/rules/missing-expect.md
|
108 | [no-suite-callback-args]: docs/rules/no-suite-callback-args.md
|
109 | [valid-expect]: docs/rules/valid-expect.md
|
110 | [no-assign-spyon]: docs/rules/no-assign-spyon.md
|
111 | [no-unsafe-spy]: docs/rules/no-unsafe-spy.md
|
112 | [no-global-setup]: docs/rules/no-global-setup.md
|
113 |
|
114 | [configuring rules]: http://eslint.org/docs/user-guide/configuring#configuring-rules
|
115 |
|
116 | ## Author
|
117 |
|
118 | © 2016 Tom Vincent <git@tlvince.com> and [contributors][].
|
119 |
|
120 | [contributors]: https://github.com/tlvince/eslint-plugin-jasmine/graphs/contributors
|
121 |
|
122 | ## License
|
123 |
|
124 | Released under the [MIT license](http://tlvince.mit-license.org).
|