space-after-function-name

在函数定义中的名称后强制使用一致的间距。

¥Enforces consistent spacing after name in function definitions.

函数名与其参数列表之间的空格是可选的。

¥Whitespace between a function name and its parameter list is optional.

function withoutSpace(x) {
    // ...
}

function withSpace (x) {
    // ...
}

一些风格指南可能要求函数名称的间距一致。

¥Some style guides may require a consistent spacing for function names.

规则详情

¥Rule Details

此规则旨在在函数名称后强制使用一致的间距。它需要一个参数。如果是 "always",那么所有函数名后面必须至少有一个空格。如果 "never" 则名称和参数列表之间不应有空格。默认值为 "never"

¥This rule aims to enforce a consistent spacing after function names. It takes one argument. If it is "always" then all function names must be followed by at least one space. If "never" then there should be no spaces between the name and the parameter list. The default is "never".

此规则的错误代码示例:

¥Examples of incorrect code for this rule:

function foo (x) {
    // ...
}

var x = function named (x) {};

// When ["error", "always"]
function bar(x) {
    // ...
}

此规则的正确代码示例:

¥Examples of correct code for this rule:

function foo(x) {
    // ...
}

var x = function named(x) {};

// When ["error", "always"]
function bar (x) {
    // ...
}

版本

此规则是在 ESLint v0.11.0 中引入,并在 v1.0.0-rc-1 中删除。