eslint-plugin-prefer-arrow
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -72,2 +72,4 @@ /** | ||
if (typeof node !== 'object' || node === null) return false; | ||
if (node.type === 'FunctionDeclaration') return false; | ||
if (node.type === 'FunctionExpression') return false; | ||
if (node.type === 'ThisExpression') return true; | ||
@@ -127,3 +129,3 @@ return Object.keys(node).some(field => { | ||
if(isConstructor(node)) return; | ||
if(containsThis(node) && !isClassMethod(node)) return; | ||
if(!isClassMethod(node) && (containsThis(node.params) || containsThis(node.body))) return; | ||
if(isGeneratorFunction(node)) return; | ||
@@ -296,2 +298,2 @@ if(isGetterOrSetter(node)) return; | ||
return replaceTokens(orig, tokens, swap).replace(/ $/, '') + (parens && !semicolon ? ');' : ';'); | ||
} | ||
} |
{ | ||
"name": "eslint-plugin-prefer-arrow", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Prefer arrow functions in most cases", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,12 +24,12 @@ # eslint-plugin-prefer-arrow | ||
], | ||
"rules": [ | ||
"rules": { | ||
"prefer-arrow/prefer-arrow-functions": [ | ||
"warn", | ||
{ | ||
"disallowPrototype": true, | ||
"singleReturnOnly": false, | ||
"classPropertiesAllowed": false | ||
} | ||
] | ||
] | ||
"warn", | ||
{ | ||
"disallowPrototype": true, | ||
"singleReturnOnly": false, | ||
"classPropertiesAllowed": false | ||
} | ||
] | ||
} | ||
``` | ||
@@ -36,0 +36,0 @@ # Configuration |
@@ -37,2 +37,8 @@ /** | ||
'class foo { bar() { return "test" } }', | ||
'function foo() { return () => this; }', | ||
'function foo() { return (bar = this) => bar; }', | ||
'function foo(bar = this) { return bar; }', | ||
'const foo = function () { return () => this; }', | ||
'const foo = function () { return (bar = this) => bar; }', | ||
'const foo = function (bar = this) { return bar; }', | ||
...[ | ||
@@ -97,2 +103,6 @@ 'var foo = (bar) => {return bar();}', | ||
{code: 'function foo() { return arguments; }', errors: ['Use const or class constructors instead of named functions']}, | ||
{code: 'function foo() { return function () { return this; }; }', errors: ['Use const or class constructors instead of named functions']}, | ||
{code: 'function foo() { return function (bar = this) { return bar; }; }', errors: ['Use const or class constructors instead of named functions']}, | ||
{code: 'const foo = function () { return function (bar = this) { return bar; }; }', errors: ['Prefer using arrow functions over plain functions']}, | ||
{code: 'const foo = function () { return function () { return this; }; }', errors: ['Prefer using arrow functions over plain functions']}, | ||
{code: 'var foo = function() { return "World"; }', errors: ['Prefer using arrow functions over plain functions']}, | ||
@@ -99,0 +109,0 @@ {code: '["Hello", "World"].reduce(function(a, b) { return a + " " + b; })', errors: ['Prefer using arrow functions over plain functions']}, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28719
536