Skip to content
Permalink
Browse files

Docs: Specify default for func-style (fixes #4834)

  • Loading branch information...
IanVS committed Jan 7, 2016
1 parent ad44518 commit 0b3c01e68c990887f44a8fcf51ac5d40e8cec93f
Showing with 26 additions and 20 deletions.
  1. +26 −20 docs/rules/func-style.md
@@ -46,6 +46,32 @@ Due to these different behaviors, it is common to have guidelines as to which st

This rule is aimed at enforcing a particular type of function style throughout a JavaScript file, either declarations or expressions. You can specify which you prefer in the configuration.

### Options

#### expression

This is the default configuration. It reports an error when function declarations are used instead of function expressions.

```json
"func-style": [2, "expression"]
```

An additional option object can be added with a property `"allowArrowFunctions"`. Setting this to `true` will allow arrow functions.

```json
"func-style": [2, "expression", { "allowArrowFunctions": true }]
```

#### declaration

This reports an error if any function expressions are used where function declarations are expected. You can specify to use expressions instead:

```json
"func-style": [2, "declaration"]
```

### Examples

The following patterns are considered problems:

```js
@@ -100,26 +126,6 @@ var foo = () => {};
```


### Options

```json
"func-style": [2, "declaration"]
```

This reports an error if any function expressions are used where function declarations are expected. You can specify to use expressions instead:

```json
"func-style": [2, "expression"]
```

This configuration reports an error when function declarations are used instead of function expressions.

```json
"func-style": [2, "expression", { "allowArrowFunctions": true }]
```

This configuration works as expression setting works but does not check for arrow functions.

## When Not To Use It

If you want to allow developers to each decide how they want to write functions on their own, then you can disable this rule.

0 comments on commit 0b3c01e

Please sign in to comment.
You can’t perform that action at this time.