Skip to content

Commit

Permalink
fixes more errors
Browse files Browse the repository at this point in the history
  • Loading branch information
harryi3t committed Jan 8, 2017
1 parent 68948c2 commit 92f8356
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rules/on-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ function indent(num) {

function fixIndentation(node, arg, fixer) {
var colToIndent = 0;
if (!node.callee) {
console.log(node);
return;
}
if (node.type === 'ReturnStatement' ||
areOnSameLine(node.callee.property, node)) {
areOnSameLine(node.callee.property || node.callee, node)) {
colToIndent = node.loc.start.column + INDENT_LEVEL;
}
else
Expand All @@ -71,7 +75,7 @@ function callExpressionRule(context, callNode, returnNode) {
var functionLine = arg.loc.start.line;
var parentLine = callNode.callee.loc.end.line;

if (args.length > 1)
if (index > 0)
parentLine = args[index - 1].loc.end.line;

if (functionLine === parentLine) {
Expand Down
21 changes: 21 additions & 0 deletions tests/lib/rules/on-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,24 @@ ruleTester.run('callback where callee is MemberExpression', rule, {
errors: onNewLineErrors
}]
});

ruleTester.run('callback where callee is Identifier ' +
'and CallExpression has multiple arguments', rule, {
valid: [{
code:
'setTimeout( \n\
function () { \n\
\n\
}, \n\
1000 \n\
);'

}],
invalid: [{
code:
'setTimeout(function () { \n\
\n\
}, 1000);',
errors: onNewLineErrors
}]
});

0 comments on commit 92f8356

Please sign in to comment.