millermedeiros / esformatter

ECMAScript code beautifier/formatter
MIT License
970 stars 91 forks source link

IIFE's content incorrectly indented #410

Closed JonathanWolfe closed 8 years ago

JonathanWolfe commented 8 years ago

The contents of IIFE's are incorrectly indented by -1 indent.

Example:

/**
 * Esformatter Indenting
 */
( function initParser() {
return parser;
}() );

/**
 * Correct Indenting
 */
( function initParser() {
    return parser;
}() );
millermedeiros commented 8 years ago

uhm, I was not able to reproduce this on the latest version with the default settings - I copied the example and did pbpaste | ./bin/esformatter | pbcopy and this is the output I got:

/**
 * Esformatter Indenting
 */
(function initParser() {
  return parser;
}());

/**
 * Correct Indenting
 */
(function initParser() {
  return parser;
}());

make sure you have indent.TopLevelFunctionBlock: 1 in your settings

feel fee to reopen if problem persists and/or if you have another test case.

PS: this logic is handled by the FunctionExpression hook

JonathanWolfe commented 8 years ago

Yep, sorry. I was on the "jQuery" preset.