Search code examples
javascriptjscs

JSCS error: X and Y should have at most 2 line(s) between them at


; and $rootScope should have at most 2 line(s) between them at app/scripts/services/betslipfactory.js :

  131 |            }
   132 |            $rootScope.copyLineStatus += '</div>';
   133 |          });
---------------------^
   134 |
   135 |

1 code style errors found!

that is the error I am getting here

_.each(status.selections, function(selection) {
            $rootScope.copyLineStatus += '<div class="well">';
            $rootScope.copyLineStatus += '<strong>' + selection.teamName  + ' </strong>';
            if (selection.lineChange) {
              $rootScope.copyLineStatus += '<div class="row">';
              $rootScope.copyLineStatus += '<div class="col-md-12">';
              $rootScope.copyLineStatus += '<strong>Lines:</strong>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '<div class="row">';
              $rootScope.copyLineStatus += '<div class="col-md-6">';
              $rootScope.copyLineStatus += '<strong>Before</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.oldSpread + '(' + selection.oldMoneyLine + ')';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '<div class="col-md-6">';
              $rootScope.copyLineStatus += '<strong>Current</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.newSpread + '(' + selection.newMoneyLine + ')';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '</div>';
            }

            if (selection.timeChange) {
              $rootScope.copyLineStatus += '<div class="row">';
              $rootScope.copyLineStatus += '<div class="col-md-6">';
              $rootScope.copyLineStatus += '<strong>Previous Time:</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.oldDate + '</div>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '<div class="col-md-6">';
              $rootScope.copyLineStatus += '<strong>Current Time:</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.newDate + '</div>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '</div>';
            }

            if (selection.statusChange) {
              $rootScope.copyLineStatus += '<div class="row">';
              $rootScope.copyLineStatus += '<div class="col-md-6">';
              $rootScope.copyLineStatus += '<strong>Old Status:</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.oldStatus + '</div>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '<div class="col-md-6">';
              $rootScope.copyLineStatus += '<strong>New Status:</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.newStatus + '</div>';
              $rootScope.copyLineStatus += '</div>';
              $rootScope.copyLineStatus += '</div>';
            }

            if (selection.pitchingChangeThis) {
              $rootScope.copyLineStatus += '<div class="row">';
              $rootScope.copyLineStatus += '<div class="col-md-12">';
              $rootScope.copyLineStatus += '<strong>New Pitcher On Your Team:</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.newPlayerNameThis + '</div>';
              $rootScope.copyLineStatus += '</div>';
            }

            if (selection.pitchingChangeOther) {
              $rootScope.copyLineStatus += '<div class="row">';
              $rootScope.copyLineStatus += '<div class="col-md-12">';
              $rootScope.copyLineStatus += '<strong>New Pitcher On The Other Team:</strong>';
              $rootScope.copyLineStatus += '<div>' + selection.newPlayerNameOther + '</div>';
              $rootScope.copyLineStatus += '</div>';
            }
            $rootScope.copyLineStatus += '</div>'; //closing the '<div .well>' tag...       
          });
             //HERE IS THE ERROR ^

Solution

  • well, you probably have 2 blank lines between:

      $rootScope.copyLineStatus += '</div>'; //closing the '<div .well>' tag...       
    });
    

    and the next line of code.


    Auto fixing code

    With JSCS only

    In the console run:

    jscs "myfile.js" --fix
    

    You can also point it to a directory or a list of files. Check the documentation for more info

    In Sublime

    There's a puglin called SublimeJSCSFormatter that should do that for you. Never used it though.

    WebStorm/PHPStorm

    Just press CTRL+ALT+L or CMD+ALT+L (in mac)