eslint-plugin-array-func
Advanced tools
Comparing version 3.1.3 to 3.1.4
{ | ||
"name": "eslint-plugin-array-func", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "Rules dealing with Array functions and methods.", | ||
@@ -16,11 +16,11 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@freaktechnik/eslint-config-node": "^6.5.4", | ||
"@freaktechnik/eslint-config-test": "^6.5.4", | ||
"ava": "^1.2.1", | ||
"codecov": "^3.2.0", | ||
"@freaktechnik/eslint-config-node": "^7.0.0", | ||
"@freaktechnik/eslint-config-test": "^7.0.0", | ||
"ava": "^2.4.0", | ||
"codecov": "^3.6.5", | ||
"eclint": "^2.8.1", | ||
"eslint": "^5.14.0", | ||
"eslint-ava-rule-tester": "^3.0.0", | ||
"eslint-plugin-eslint-plugin": "^2.0.1", | ||
"nyc": "^13.3.0" | ||
"eslint": "^6.8.0", | ||
"eslint-ava-rule-tester": "^4.0.0", | ||
"eslint-plugin-eslint-plugin": "^2.2.1", | ||
"nyc": "^15.0.0" | ||
}, | ||
@@ -27,0 +27,0 @@ "peerDependencies": { |
# eslint-plugin-array-func | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/freaktechnik/eslint-plugin-array-func.svg)](https://greenkeeper.io/) [![Build Status](https://travis-ci.org/freaktechnik/eslint-plugin-array-func.svg?branch=master)](https://travis-ci.org/freaktechnik/eslint-plugin-array-func) [![codecov](https://codecov.io/gh/freaktechnik/eslint-plugin-array-func/branch/master/graph/badge.svg)](https://codecov.io/gh/freaktechnik/eslint-plugin-array-func) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/freaktechnik/eslint-plugin-array-func.svg)](https://greenkeeper.io/) [![Build Status](https://travis-ci.com/freaktechnik/eslint-plugin-array-func.svg?branch=master)](https://travis-ci.com/freaktechnik/eslint-plugin-array-func) [![codecov](https://codecov.io/gh/freaktechnik/eslint-plugin-array-func/branch/master/graph/badge.svg)](https://codecov.io/gh/freaktechnik/eslint-plugin-array-func) | ||
@@ -247,6 +247,6 @@ Rules for Array functions and methods. | ||
---- | ----------- | ------- | ||
`from-map` | Error | Yes | ||
`no-unnecessary-this-arg` | Error | Sometimes | ||
`prefer-array-from` | Error | Yes | ||
`avoid-reverse` | Error | Yes | ||
`array-func/from-map` | Error | Yes | ||
`array-func/no-unnecessary-this-arg` | Error | Sometimes | ||
`array-func/prefer-array-from` | Error | Yes | ||
`array-func/avoid-reverse` | Error | Yes | ||
@@ -270,10 +270,10 @@ #### Using the Configuration | ||
---- | ----------- | ------- | ||
`from-map` | Error | Yes | ||
`no-unnecessary-this-arg` | Error | Sometimes | ||
`prefer-array-from` | Error | Yes | ||
`avoid-reverse` | Error | Yes | ||
`prefer-flat-map` | Error | Yes | ||
`prefer-flat` | Error | Yes | ||
`array-func/from-map` | Error | Yes | ||
`array-func/no-unnecessary-this-arg` | Error | Sometimes | ||
`array-func/prefer-array-from` | Error | Yes | ||
`array-func/avoid-reverse` | Error | Yes | ||
`array-func/prefer-flat-map` | Error | Yes | ||
`array-func/prefer-flat` | Error | Yes | ||
## License | ||
The `array-func` plugin is licensed under the [MIT License](LICENSE). |
@@ -15,3 +15,3 @@ /** | ||
docs: { | ||
description: "Prefer using Array.from over spreading an iterable in an array literal.", | ||
description: "Prefer using Array.from over spreading an iterable in an array literal. Using Array.from also preserves the original type of TypedArrays while mapping.", | ||
recommended: true | ||
@@ -21,3 +21,3 @@ }, | ||
fixable: "code", | ||
type: "suggestion" | ||
type: "problem" | ||
}, | ||
@@ -24,0 +24,0 @@ create(context) { |
@@ -9,7 +9,7 @@ /** | ||
const firstElement = (arr) => { | ||
const [ el ] = arr; | ||
return el; | ||
}, | ||
SECOND = 1; | ||
const | ||
firstElement = ([ first ]) => first, | ||
secondElement = ([ | ||
, second | ||
]) => second; | ||
@@ -40,6 +40,11 @@ module.exports = { | ||
}, | ||
'CallExpression[callee.type="MemberExpression"][callee.property.name="reduce"] > *:function > CallExpression[callee.type="MemberExpression"][callee.property.name="concat"]'(node) { | ||
if(node.parent.parent.arguments.length > SECOND && node.parent.parent.arguments[SECOND].type === "ArrayExpression" && | ||
firstElement(node.arguments).name === node.parent.params[SECOND].name && | ||
node.callee.object.name === firstElement(node.parent.params).name) { | ||
'CallExpression[callee.type="MemberExpression"][callee.property.name="reduce"][arguments.length=2][arguments.1.type=ArrayExpression][arguments.1.elements.length=0] > *:function[params.length=2][params.0.type=Identifier][params.1.type=Identifier] > CallExpression[callee.type="MemberExpression"][callee.property.name="concat"][arguments.length=1][arguments.0.type=Identifier]'(node) { | ||
const reduceCallbackParams = node.parent.params; | ||
// arr.reducer((a, b) => a.concat(b), []) | ||
// "concat" function must be called on "a" and concat argument must be "b". | ||
if( | ||
firstElement(node.arguments).name === secondElement(reduceCallbackParams).name && | ||
node.callee.object.name === firstElement(reduceCallbackParams).name | ||
) { | ||
context.report({ | ||
@@ -46,0 +51,0 @@ node: node.parent.parent, |
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
27314
424