generator-star-spacing
Configuration
Enforce consistent spacing around * operators in generator functions.
Rule Details
Generators are a type of function in ECMAScript 6 that can return multiple values over time. These functions are indicated by placing an * after the function keyword.
To keep a sense of consistency when using generators this rule standardizes the spacing around the * token.
Examples of incorrect code for this rule with the default "before" option:
Examples of correct code for this rule with the default "before" option:
Options
This rule takes one option, which can be a string or an object.
String shorthands:
"before"(default) requires a space before the*and forbids a space after — equivalent to{ "before": true, "after": false }."after"requires a space after the*and forbids a space before — equivalent to{ "before": false, "after": true }."both"requires a space both before and after the*— equivalent to{ "before": true, "after": true }."neither"forbids a space both before and after the*— equivalent to{ "before": false, "after": false }.
Object option:
"before"(boolean, defaulttrue) — controls the space before the*token."after"(boolean, defaultfalse) — controls the space after the*token.
Per-kind overrides (each accepts a shorthand string or a { "before", "after" } object):
"named"— overrides the top-level setting for named functions."anonymous"— overrides the top-level setting for anonymous function expressions."method"— overrides the top-level setting for class methods and object shorthand methods."shorthand"— overrides the"method"setting specifically for object shorthand methods; falls back to"method"when omitted.
after
Examples of incorrect code for this rule with the "after" option:
Examples of correct code for this rule with the "after" option:
both
Examples of incorrect code for this rule with the "both" option:
Examples of correct code for this rule with the "both" option:
neither
Examples of incorrect code for this rule with the "neither" option:
Examples of correct code for this rule with the "neither" option:
Overrides per function type
Examples of incorrect code for this rule with { "before": false, "after": true, "anonymous": "neither", "method": "both" }:
Examples of correct code for this rule with { "before": false, "after": true, "anonymous": "neither", "method": "both" }: