简体   繁体   中英

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 ^

This is a little aside from what the OP was after but may serve others that look for this error:

If you want to be able to have multiple line breaks to space out your code for a bit more readability, you can remove this line from your .jscsrc file. Note that you cannot set this to false as it's either true or needs to be removed.

"disallowMultipleLineBreaks": true

While this gives you more flexibility, that also means you may need to apply a common approach across your development team to stay consistent.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM