1 # generator-star: enforce consistent spacing around the asterisk in generator functions
3 (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [generator-star-spacing](generator-star-spacing.md) rule.
5 Generators are a new type of function in ECMAScript 6 that can return multiple values over time.
6 These special functions are indicated by placing an `*` after the `function` keyword.
8 Here is an example of a generator function:
13 function* generator() {
24 function *generator() {
30 This is valid as well:
35 function * generator() {
41 To keep a sense of consistency when using generators this rule enforces a single position for the `*`.
45 This rule enforces that the `*` is either placed next to the `function` keyword or the name of the function. The single
46 option for this rule is a string specifying the placement of the asterisk. For this option you may pass
47 `"start"`, `"middle"` or `"end"`. The default is `"end"`.
49 You can set the style in configuration like this:
52 "generator-star": ["error", "start"]
55 When using `"start"` this placement will be enforced:
60 function* generator() {
64 When using `"middle"` this placement will be enforced:
69 function * generator() {
73 When using `"end"` this placement will be enforced:
78 function *generator() {
82 When using the expression syntax `"start"` will be enforced here:
87 var generator = function* () {
91 When using the expression syntax `"middle"` will be enforced here:
96 var generator = function * () {
100 When using the expression syntax `"end"` will be enforced here:
105 var generator = function *() {
109 When using the expression syntax this is valid for both `"start"` and `"end"`:
114 var generator = function*() {
118 The shortened object literal syntax for generators is not affected by this rule.
120 ## When Not To Use It
122 If your project will not be using generators you do not need this rule.
126 * [Understanding ES6: Generators](https://leanpub.com/understandinges6/read/#leanpub-auto-generators)