eslint-plugin-array-func
Advanced tools
Comparing version 3.1.1 to 3.1.2
{ | ||
"name": "eslint-plugin-array-func", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "Rules dealing with Array functions and methods.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -43,2 +43,11 @@ /** | ||
fix(fixer) { | ||
if(reversed === "lastIndexOf" || reversed === "indexOf") { | ||
return [ | ||
fixer.insertTextBefore(parent.callee, `${parent.callee.object.name}.length - 1 - `), | ||
fixer.replaceTextRange([ | ||
parent.callee.property.start, | ||
node.callee.property.end | ||
], reversed) | ||
]; | ||
} | ||
return fixer.replaceTextRange([ | ||
@@ -45,0 +54,0 @@ parent.callee.property.start, |
@@ -10,3 +10,3 @@ /** | ||
docs: { | ||
description: "Prefer using the flatMap over an immediate .map() call after a .flat().", | ||
description: "Prefer using the flatMap over an immediate .flat() call after a .map().", | ||
recommended: true | ||
@@ -19,3 +19,3 @@ }, | ||
return { | ||
'CallExpression[callee.type="MemberExpression"] > MemberExpression[property.name="map"] > CallExpression[callee.type="MemberExpression"][callee.property.name="flat"]'(node) { | ||
'CallExpression[callee.type="MemberExpression"] > MemberExpression[property.name="flat"] > CallExpression[callee.type="MemberExpression"][callee.property.name="map"]'(node) { | ||
const parent = node, | ||
@@ -31,8 +31,14 @@ callee = node.parent; | ||
}, | ||
message: "Use flatMap instead of .flat().map()", | ||
message: "Use flatMap instead of .map().flat()", | ||
fix(fixer) { | ||
return fixer.replaceTextRange([ | ||
parent.callee.property.start, | ||
node.callee.property.end | ||
], 'flatMap'); | ||
return [ | ||
fixer.replaceTextRange([ | ||
parent.callee.property.start, | ||
parent.callee.property.end | ||
], 'flatMap'), | ||
fixer.removeRange([ | ||
callee.object.end, | ||
callee.parent.end | ||
]) | ||
]; | ||
} | ||
@@ -39,0 +45,0 @@ }); |
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
27422
424