       nonWhitespaceCharacters = nonWhitespaceCharacters.length
 
     if grammar is 'source.json' or grammar is 'source.js'
-      @formatJavascript editor
+      @formatJavascript(editor)
 
       nonWhitespaceCount = 0
       text = editor.getText()

      mainCursor.setBufferPosition(newCursorPosition)

    else
      @displayUnsupportedLanguageNotification state

  formatJavascript: (editor) ->
    editorSettings = atom.config.get('editor')

    opts.indent_size = editorSettings.tabLength
    opts.wrap_line_length = editorSettings.preferredLineLength

    if @selectionsAreEmpty(editor)
      editor.setText(jsbeautify(editor.getText(), opts))

    else
