eslint-plugin-prefer-arrow-functions
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -25,2 +25,3 @@ import { TSESTree } from '@typescript-eslint/types'; | ||
allowNamedFunctions: boolean; | ||
allowObjectProperties: boolean; | ||
classPropertiesAllowed: boolean; | ||
@@ -27,0 +28,0 @@ disallowPrototype: boolean; |
@@ -7,2 +7,3 @@ "use strict"; | ||
allowNamedFunctions: false, | ||
allowObjectProperties: false, | ||
classPropertiesAllowed: false, | ||
@@ -9,0 +10,0 @@ disallowPrototype: false, |
@@ -37,3 +37,4 @@ import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/utils'; | ||
isIgnored(fn: AnyFunction): boolean; | ||
isObjectProperty(fn: AnyFunction): boolean; | ||
isSafeTransformation(fn: TSESTree.Node): fn is AnyFunction; | ||
} |
@@ -130,2 +130,10 @@ "use strict"; | ||
} | ||
isObjectProperty(fn) { | ||
return this.sourceCode | ||
.getAncestors(fn) | ||
.reverse() | ||
.some((ancestor) => { | ||
return ancestor.type === utils_1.AST_NODE_TYPES.Property; | ||
}); | ||
} | ||
isSafeTransformation(fn) { | ||
@@ -150,2 +158,4 @@ const isSafe = this.isAnyFunction(fn) && | ||
return false; | ||
if (this.isObjectProperty(fn) && this.options.allowObjectProperties) | ||
return false; | ||
if (this.hasNameAndIsExportedAsDefaultExport(fn)) | ||
@@ -152,0 +162,0 @@ return false; |
@@ -33,2 +33,6 @@ "use strict"; | ||
}, | ||
allowObjectProperties: { | ||
default: config_1.DEFAULT_OPTIONS.allowObjectProperties, | ||
type: 'boolean', | ||
}, | ||
classPropertiesAllowed: { | ||
@@ -35,0 +39,0 @@ default: config_1.DEFAULT_OPTIONS.classPropertiesAllowed, |
{ | ||
"name": "eslint-plugin-prefer-arrow-functions", | ||
"description": "Convert functions to arrow functions", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"author": "Jamie Mason (https://github.com/JamieMason)", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/JamieMason/eslint-plugin-prefer-arrow-functions/issues", |
@@ -24,2 +24,3 @@ # eslint-plugin-prefer-arrow-functions | ||
"allowNamedFunctions": false, | ||
"allowObjectProperties": false, | ||
"classPropertiesAllowed": false, | ||
@@ -45,2 +46,12 @@ "disallowPrototype": false, | ||
### `allowObjectProperties` | ||
If set to true, the rule won't report named methods such as | ||
```js | ||
const myObj = { | ||
hello() {} | ||
} | ||
``` | ||
### `classPropertiesAllowed` | ||
@@ -47,0 +58,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43102
518
85
0