mihai-vlc / sublime-jsfmt

jsfmt plugin for Sublime Text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues with indentation

brettlangdon opened this issue · comments

Over at rdio/jsfmt#179 we have a user which is seeing an issue which might be related to sublime-jsfmt.

They are seeing some odd indentation issues, for example:

function test() {
    var mytest;
}

module.exports = function test() {
    var mytest;
}

Gets formatted to:

function test() {
    var mytest;
}

module.exports = function test() {
var mytest;
}

They are using node@4.2.1 and this is the package.json file from sublime-text that they are using:

{
  "name": "sublime-jsfmt",
  "dependencies": {
    "esformatter-braces": "^1.2.1",
    "esformatter-dot-notation": "^1.3.1",
    "esformatter-quotes": "^1.0.3",
    "esformatter-semicolons": "^1.1.1",
    "extend": "^3.0.0",
    "get-stdin": "^4.0.1",
    "jsfmt": "^0.5.0"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "private": true
}

I have been unable to reproduce this issue with just jsfmt, which leads me to believe it might be related to sublime-jsfmt. If anyone has seen this issue before or has any insights into what might be happening, it would be greatly appreciated. (I do not use Sublime, so not sure where to begin).

/cc @damienleroux

sublime-jsfmt doesn't alter the formatted code in any way.

It looks to me like a configuration issue caused by the jquery preset here.
I managed to fix the issue using this options:

    "options":
    {
        "preset": "jquery",
        "indent":
        {
            "value": "    ",
            "TopLevelFunctionBlock" : 1
        }
    }

@damienleroux can you add the configuration above to your sublime-jsfmt.sublime-settings and post here if it fixes the issue ?

related issue: #32

Hi,

Thank very much you for the solution. Adding "TopLevelFunctionBlock" resolved my problem.

You can close the issue.

Issue closed.