eslint-plugin-loopback-options
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -46,19 +46,2 @@ /** | ||
return { | ||
// ExpressionStatement: function(node) { | ||
// if (node.expression && node.expression.callee) { | ||
// var exp = node.expression; | ||
// if (exp.callee.property.name === 'save' && exp.arguments.length === 0) { | ||
// context.report(node, 'Options should be passed to save() function'); | ||
// } | ||
// if ( | ||
// exp.callee.property.name === 'create' && | ||
// exp.arguments[exp.arguments.length - 1].name !== 'options' | ||
// ) { | ||
// context.report( | ||
// node, | ||
// "'options' should be the last argument passed to create() function", | ||
// ); | ||
// } | ||
// } | ||
// }, | ||
CallExpression: function(node) { | ||
@@ -72,7 +55,28 @@ const memberExpression = node.callee; | ||
} | ||
if ( | ||
memberExpression.property.name === 'create' && | ||
node.arguments[node.arguments.length - 1].name !== 'options' | ||
) { | ||
context.report(node, "'options' should be the last argument passed to create() function"); | ||
if (memberExpression.property.name === 'create') { | ||
if ( | ||
node.arguments[node.arguments.length - 1].type === 'Identifier' && | ||
node.arguments[node.arguments.length - 1].name !== 'options' | ||
) { | ||
context.report( | ||
node, | ||
"'options' should be the last argument passed to create() function", | ||
); | ||
} else { | ||
const lastArgument = node.arguments[node.arguments.length - 1]; | ||
if ( | ||
lastArgument && | ||
['FunctionExpression', 'ArrowFunctionExpression'].indexOf(lastArgument.type) !== -1 | ||
) { | ||
if ( | ||
node.arguments[node.arguments.length - 2].type === 'Identifier' && | ||
node.arguments[node.arguments.length - 2].name !== 'options' | ||
) { | ||
context.report( | ||
node, | ||
"'options' should be the last argument passed to create() function", | ||
); | ||
} | ||
} | ||
} | ||
} | ||
@@ -79,0 +83,0 @@ }, |
{ | ||
"name": "eslint-plugin-loopback-options", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Checks if options argument is passed to write functions", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
38942
161