2 title: space-before-function-parentheses
7 - space-return-throw-case
10 Enforces consistent spacing before opening parenthesis in function definitions.
12 (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [space-before-function-paren](space-before-function-paren) rule. The name of the rule changed from "parentheses" to "paren" for consistency with the names of other rules.
14 When formatting a function, whitespace is allowed between the function name or `function` keyword and the opening paren. Named functions also require a space between the `function` keyword and the function name, but anonymous functions require no whitespace. For example:
17 function withoutSpace(x) {
21 function withSpace (x) {
25 var anonymousWithoutSpace = function() {};
27 var anonymousWithSpace = function () {};
30 Style guides may require a space after the `function` keyword for anonymous functions, while others specify no whitespace. Similarly, the space after a function name may or may not be required.
34 This rule aims to enforce consistent spacing before function parentheses and as such, will warn whenever whitespace doesn't match the preferences specified.
36 This rule takes one argument. If it is `"always"`, which is the default option, all named functions and anonymous functions must have space before function parentheses. If `"never"` then all named functions and anonymous functions must not have space before function parentheses. If you want different spacing for named and anonymous functions you can pass a configuration object as the rule argument to configure those separately (e. g. `{"anonymous": "always", "named": "never"}`).
38 Examples of **incorrect** code for this rule with the default `"always"` option:
49 var bar = function() {
53 var bar = function foo() {
72 Examples of **correct** code for this rule with the default `"always"` option:
83 var bar = function () {
87 var bar = function foo () {
106 Examples of **incorrect** code for this rule with the `"never"` option:
117 var bar = function () {
121 var bar = function foo () {
140 Examples of **correct** code for this rule with the `"never"` option:
151 var bar = function() {
155 var bar = function foo() {
174 Examples of **incorrect** code for this rule with the `{"anonymous": "always", "named": "never"}` option:
185 var bar = function() {
204 Examples of **correct** code for this rule with the `{"anonymous": "always", "named": "never"}` option:
215 var bar = function () {
234 Examples of **incorrect** code for this rule with the `{"anonymous": "never", "named": "always"}` option:
245 var bar = function () {
264 Examples of **correct** code for this rule with the `{"anonymous": "never", "named": "always"}` option:
275 var bar = function() {
294 ## When Not To Use It
296 You can turn this rule off if you are not concerned with the consistency of spacing before function parenthesis.