Skip to content

Commit

Permalink
Fix: Keep indentation when fixing padded-blocks "never" (fixes esli…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mardak committed Jun 17, 2016
1 parent 414206c commit 8fa380d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/padded-blocks.js
Expand Up @@ -190,7 +190,7 @@ module.exports = {
node: node,
loc: { line: openBrace.loc.start.line, column: openBrace.loc.start.column },
fix: function(fixer) {
return fixer.replaceTextRange([openBrace.end, nextToken.start], "\n");
return fixer.replaceTextRange([openBrace.end, nextToken.start - nextToken.loc.start.column], "\n");
},
message: NEVER_MESSAGE
});
Expand Down
13 changes: 12 additions & 1 deletion tests/lib/rules/padded-blocks.js
Expand Up @@ -307,7 +307,7 @@ ruleTester.run("padded-blocks", rule, {
},
{
code: "{\n\n\n a();\n\n\n}",
output: "{\na();\n}",
output: "{\n a();\n}",
options: ["never"],
errors: [
{
Expand All @@ -331,6 +331,17 @@ ruleTester.run("padded-blocks", rule, {
}
]
},
{
code: "{\n\n\ta();\n}",
output: "{\n\ta();\n}",
options: ["never"],
errors: [
{
message: NEVER_MESSAGE,
line: 1
}
]
},
{
code: "{\na();\n\n}",
output: "{\na();\n}",
Expand Down

0 comments on commit 8fa380d

Please sign in to comment.