eslint-plugin-unicorn
Advanced tools
Comparing version 34.0.0 to 34.0.1
{ | ||
"name": "eslint-plugin-unicorn", | ||
"version": "34.0.0", | ||
"version": "34.0.1", | ||
"description": "Various awesome ESLint rules", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -136,2 +136,4 @@ 'use strict'; | ||
notFunctionSelector('arguments.0'), | ||
// Ignore all `CallExpression`s include `function.bind()` | ||
'[arguments.0.type!="CallExpression"]', | ||
'[arguments.0.type!="FunctionExpression"]', | ||
@@ -138,0 +140,0 @@ '[arguments.0.type!="ArrowFunctionExpression"]' |
'use strict'; | ||
const {hasSideEffect} = require('eslint-utils'); | ||
const {methodCallSelector} = require('./selectors/index.js'); | ||
const {methodCallSelector, notFunctionSelector} = require('./selectors/index.js'); | ||
const {removeArgument} = require('./fix/index.js'); | ||
const {getParentheses, getParenthesizedText} = require('./utils/parentheses.js'); | ||
const shouldAddParenthesesToMemberExpressionObject = require('./utils/should-add-parentheses-to-member-expression-object.js'); | ||
const {isNodeMatches} = require('./utils/is-node-matches.js'); | ||
@@ -17,16 +18,58 @@ const ERROR = 'error'; | ||
const selector = methodCallSelector({ | ||
names: [ | ||
'every', | ||
'filter', | ||
'find', | ||
'findIndex', | ||
'flatMap', | ||
'forEach', | ||
'map', | ||
'some' | ||
], | ||
length: 2 | ||
}); | ||
const ignored = [ | ||
'lodash.every', | ||
'_.every', | ||
'underscore.every', | ||
'lodash.filter', | ||
'_.filter', | ||
'underscore.filter', | ||
'Vue.filter', | ||
'lodash.find', | ||
'_.find', | ||
'underscore.find', | ||
'lodash.findIndex', | ||
'_.findIndex', | ||
'underscore.findIndex', | ||
'lodash.flatMap', | ||
'_.flatMap', | ||
'lodash.forEach', | ||
'_.forEach', | ||
'React.Children.forEach', | ||
'Children.forEach', | ||
'lodash.map', | ||
'_.map', | ||
'underscore.map', | ||
'React.Children.map', | ||
'Children.map', | ||
'jQuery.map', | ||
'$.map', | ||
'lodash.some', | ||
'_.some', | ||
'underscore.some' | ||
]; | ||
const selector = [ | ||
methodCallSelector({ | ||
names: [ | ||
'every', | ||
'filter', | ||
'find', | ||
'findIndex', | ||
'flatMap', | ||
'forEach', | ||
'map', | ||
'some' | ||
], | ||
length: 2 | ||
}), | ||
notFunctionSelector('arguments.0') | ||
].join(''); | ||
function removeThisArgument(callExpression, sourceCode) { | ||
@@ -67,3 +110,8 @@ return fixer => removeArgument(fixer, callExpression.arguments[1], sourceCode); | ||
[selector](callExpression) { | ||
const method = callExpression.callee.property.name; | ||
const {callee} = callExpression; | ||
if (isNodeMatches(callee, ignored)) { | ||
return; | ||
} | ||
const method = callee.property.name; | ||
const [callback, thisArgument] = callExpression.arguments; | ||
@@ -70,0 +118,0 @@ |
'use strict'; | ||
const not = require('./negation.js'); | ||
@@ -21,3 +22,2 @@ // AST Types: | ||
'AwaitExpression', | ||
'CallExpression', | ||
'LogicalExpression', | ||
@@ -29,6 +29,16 @@ 'NewExpression', | ||
const notFunctionSelector = node => [ | ||
...[...impossibleNodeTypes, ...mostLikelyNotNodeTypes].map(type => `[${node}.type!="${type}"]`), | ||
`:not([${node}.type="Identifier"][${node}.name="undefined"])` | ||
].join(''); | ||
const notFunctionSelector = node => not([ | ||
[...impossibleNodeTypes, ...mostLikelyNotNodeTypes].map(type => `[${node}.type="${type}"]`), | ||
`[${node}.type="Identifier"][${node}.name="undefined"]`, | ||
[ | ||
`[${node}.type="CallExpression"]`, | ||
not([ | ||
`[${node}.callee.type="MemberExpression"]`, | ||
`[${node}.callee.optional!=true]`, | ||
`[${node}.callee.computed!=true]`, | ||
`[${node}.callee.property.type="Identifier"]`, | ||
`[${node}.callee.property.name="bind"]` | ||
].join('')) | ||
].join('') | ||
]); | ||
@@ -35,0 +45,0 @@ module.exports = { |
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
421403
13718