Skip to content

Commit

Permalink
Fix: key-spacing checks ObjectExpression is multiline (fixes #5479)
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumazure committed Mar 5, 2016
1 parent ef341be commit 38eb7f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/key-spacing.js
Expand Up @@ -370,7 +370,7 @@ module.exports = function(context) {

return {
"Property": function(node) {
verifySpacing(node, isSingleLine(node) ? singleLineOptions : multiLineOptions);
verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
}
};

Expand Down
19 changes: 19 additions & 0 deletions tests/lib/rules/key-spacing.js
Expand Up @@ -479,6 +479,25 @@ ruleTester.run("key-spacing", rule, {
"beforeColon": false
}
}]
}, {
code: [
"var obj = {",
" foobar: 42,",
" bat: 2",
"};"
].join("\n"),
options: [{
singleLine: {
beforeColon: false,
afterColon: true,
mode: "strict"
},
multiLine: {
beforeColon: false,
afterColon: true,
mode: "minimum"
}
}]
}],

invalid: [{
Expand Down

0 comments on commit 38eb7f1

Please sign in to comment.