non-arrow functions are forbidden Open
.map(function (v) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Rule: only-arrow-functions
Disallows traditional (non-arrow) function expressions.
Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).
Rationale
Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.
Config
Two arguments may be optionally provided:
-
"allow-declarations"
allows standalone function declarations. -
"allow-named-functions"
allows the expressionfunction foo() {}
but notfunction() {}
.
Examples
"only-arrow-functions": true
"only-arrow-functions": true,allow-declarations,allow-named-functions
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"allow-declarations",
"allow-named-functions"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.
non-arrow functions are forbidden Open
.filter(function (v) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Rule: only-arrow-functions
Disallows traditional (non-arrow) function expressions.
Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).
Rationale
Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.
Config
Two arguments may be optionally provided:
-
"allow-declarations"
allows standalone function declarations. -
"allow-named-functions"
allows the expressionfunction foo() {}
but notfunction() {}
.
Examples
"only-arrow-functions": true
"only-arrow-functions": true,allow-declarations,allow-named-functions
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"allow-declarations",
"allow-named-functions"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.