简体   繁体   English

JSCS错误:X和Y之间最多应有2行

[英]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 : 和$ rootScope之间应在app / scripts / services / betslipfactory.js之间最多包含2行:

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

1 code style errors found! 找到1个代码样式错误!

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: 这与OP的要求略有不同,但可能会为其他人寻找该错误:

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. 如果您希望能够有多个换行符来分隔代码,以提高可读性,则可以从.jscsrc文件中删除此行。 Note that you cannot set this to false as it's either true or needs to be removed. 请注意,您不能将其设置为false,因为它是true或需要删除。

"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 仅使用JSCS

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. 有一个名为SublimeJSCSFormatter的puglin应该为您执行此操作。 Never used it though. 虽然从未使用过。

WebStorm/PHPStorm WebStorm / PHPStorm

Just press CTRL+ALT+L or CMD+ALT+L (in mac) 只需按CTRL+ALT+LCMD+ALT+L (在Mac中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 $('x &gt; y')、$('y'、'x') 和 $('x y') 有什么区别? - What's the difference between $('x > y'), $('y', 'x'), and $('x y')? jscs 错误:validateLineBreaks:filename.js 处的换行符无效 - jscs error : validateLineBreaks: Invalid line break at filename.js 如何为代码的特定部分禁用JSCS验证:行必须最多为120个字符 - How to disable JSCS validation for a specific part of code: Line must be at most 120 characters 查找具有x类但不具有y类的Divs - Find Divs with Class x but should not have class y JSCS行要长,当其不行时 - JSCS line to long, when its not 如何将X和Y线的点移动到不同的数组Kineticjs - How to move X and Y line's points to different array Kineticjs 检查输入时出错:期望dense_Dense1_input具有x维度。 但得到了形状为y,z的数组 - Error when checking input: expected dense_Dense1_input to have x dimension(s). but got array with shape y,z “function xy()”和“xy = function()”之间有什么区别? - What's the difference between “function x.y()” and “x.y = function ()”? y中的x与y [x]之间的区别 - Difference between `x in y` vs `y[x]` for(var x in array)和for(var x = 0,y = array.length; x之间的性能差异 - Performance's difference between for (var x in array) and for (var x=0, y= array.length; x<y; x++)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM