簡體   English   中英

使用jshint強制執行2個空格縮進

[英]enforce 2 space indentation with jshint

我有一個使用此配置的.jshintrc文件:

{
  "indent": 2
}

我有一個js文件,看起來像這樣:

var hello = angular.module('hello', ['hello.controllers']);

angular.module('hello.controllers', []).
controller('MainCtrl', ['$scope', function ($scope) {

  'use strict';

  // hello msg
    var helloMsg = 'Some Awesome Things';
  $scope.helloMsg = helloMsg;
}]);

當我在文件上運行jshint時,不會引發任何錯誤。

注意,行var helloMsg = 'Some Awesome Things'; 縮進兩個額外的空格。

我需要怎么做才能使jshint在上面的代碼上引發錯誤?

您是否正在使用版本> = 2.5.0? 如果是這樣,似乎他們將其刪除了:

縮進不再提供有關縮進級別的警告

https://github.com/jshint/jshint/releases/tag/2.5.0

如何執行<div>標簽來使用頁面中的可用空間?</div><div id="text_translate"><p> 我正在開發一個示例網站來學習 CSS 和 HTML。 在頁面頂部創建了水平導航欄、側導航欄和歡迎消息。 當點擊任何鏈接時,相應的 Html 文件將被加載到“mainContent”上。 除了“mainContent”沒有占用頁面的剩余空間外,所有內容都按預期工作。 請告訴我缺少什么。 </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> /* Add a black background color to the top navigation */.topnav { background-color: #111; margin-left:160px; width: 90%; height:10%; overflow-x: hidden; /* Disable horizontal scroll */ } /* Style the links inside the navigation bar */.topnav a { float: left; color: green; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; font-family: sans-serif; } /* Change the color of links on hover */.topnav a:hover { background-color: Green; color: black; } /* Add a color to the active/current link */.topnav a.active { color: White; } /* The sidebar menu */.sidenav { margin-top: 0; height: 80%; /* Full-height: remove this if you want "auto" height */ width: 160px; /* Set the width of the sidebar */ position: absolute; /* Fixed Sidebar (stay in place on scroll) */ z-index: 1; /* Stay on top */ top: 1000; /* Stay at the top */ left: 0; background-color: #00A555; /* Black */ overflow-x: hidden; /* Disable horizontal scroll */ display: block; font-family: sans-serif; } /* The navigation menu links */.sidenav a { padding: 6px 8px 6px 16px; text-decoration: none; font-size: 17px; color: black; display: block; } /* When you mouse over the navigation links, change their color */.sidenav a:hover { color: #f1f1f1; } /* Style page content */.main { margin-left: 160px; /* Same as the width of the sidebar */ /*padding: 0px 10px;*/ /*top: auto; position: static;*/ overflow: auto; background-color: #FFF; padding-top: 20px; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;:DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;XYZ Hostel&lt;/title&gt; &lt;style&gt; li { display; inline. } &lt;/style&gt; &lt;/head&gt; &lt;link rel="stylesheet" href="divCss.css"&gt; &lt;body&gt; &lt;script&gt; function lurl(page) { let node = document;getElementById('mainContent'); let url = '&lt;object type="text/html" data=' + "\""+ page + "\"" + '&gt;&lt;/object&gt;'. node;innerHTML = url: } &lt;/script&gt; &lt;div id="container"&gt; &lt;div id="Welcome"&gt; &lt;table style="width. 100%"&gt; &lt;tr&gt; &lt;td&gt; &lt;div&gt; &lt;img alt="Hostel" src="hostel1:webp" width="200" height="100"&gt; &lt;/div&gt; &lt;/td&gt; &lt;td align="right"&gt; &lt;div&gt; &lt;h2 style="color; black: font-family; Lucida Calligraphy: font-style; black:"&gt;Welcome to XYZ Hostel&lt;/h2&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div class="topnav"&gt; &lt;ul style="list-style; none: padding-left; 0." &gt; &lt;li&gt;&lt;a class="active" href="#" onclick="lurl('Student_Home.html')"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Student_2.html')"&gt;Login&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Teacher_3.html')"&gt;Room Details&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Marks:html')"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="menuOption"&gt; &lt;;-- Side navigation --&gt; &lt;div class="sidenav"&gt; &lt;ul style="list-style: none. padding-left. 0"&gt; &lt;li&gt;&lt;a class="active" href="#" onclick="lurl('Student_Home.html')"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Student_2.html')"&gt;Login&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Teacher_3:html')"&gt;Room Details&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Marks.html')"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="mainContent" class="main"&gt; &lt;!-- iframe id="contentPage" height="600" width="1200" style="border: 0"&gt; &lt;/iframe --&gt; &lt;/div&gt; &lt;footer&gt; Thank you &lt;/footer&gt; &lt;/body&gt; &lt;/html&gt;</pre></div></div><p></p><p> <a href="https://i.stack.imgur.com/VxqHB.png" rel="nofollow noreferrer">在此處輸入圖像描述</a></p></div>

[英]How to enforce <DIV> tag to use the free space in a page?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 禁用JSHint縮進僅檢查特定文件 JSHint不喜歡我的縮進 VS2012:與JSHint一起使用時縮進JavaScript中的switch case JSHINT:有沒有辦法忽略camelCase only屬性並在變量和函數上強制執行它 JSHINT:匿名&#39;函數&#39;后如何禁用警告缺少空格 ESLint &gt; 自動美化和空格縮進 如何在Visual Studio 2013中抑制JSHint“JSCS:非法空間”警告? 如何執行<div>標簽來使用頁面中的可用空間?</div><div id="text_translate"><p> 我正在開發一個示例網站來學習 CSS 和 HTML。 在頁面頂部創建了水平導航欄、側導航欄和歡迎消息。 當點擊任何鏈接時,相應的 Html 文件將被加載到“mainContent”上。 除了“mainContent”沒有占用頁面的剩余空間外,所有內容都按預期工作。 請告訴我缺少什么。 </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> /* Add a black background color to the top navigation */.topnav { background-color: #111; margin-left:160px; width: 90%; height:10%; overflow-x: hidden; /* Disable horizontal scroll */ } /* Style the links inside the navigation bar */.topnav a { float: left; color: green; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; font-family: sans-serif; } /* Change the color of links on hover */.topnav a:hover { background-color: Green; color: black; } /* Add a color to the active/current link */.topnav a.active { color: White; } /* The sidebar menu */.sidenav { margin-top: 0; height: 80%; /* Full-height: remove this if you want "auto" height */ width: 160px; /* Set the width of the sidebar */ position: absolute; /* Fixed Sidebar (stay in place on scroll) */ z-index: 1; /* Stay on top */ top: 1000; /* Stay at the top */ left: 0; background-color: #00A555; /* Black */ overflow-x: hidden; /* Disable horizontal scroll */ display: block; font-family: sans-serif; } /* The navigation menu links */.sidenav a { padding: 6px 8px 6px 16px; text-decoration: none; font-size: 17px; color: black; display: block; } /* When you mouse over the navigation links, change their color */.sidenav a:hover { color: #f1f1f1; } /* Style page content */.main { margin-left: 160px; /* Same as the width of the sidebar */ /*padding: 0px 10px;*/ /*top: auto; position: static;*/ overflow: auto; background-color: #FFF; padding-top: 20px; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;:DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;XYZ Hostel&lt;/title&gt; &lt;style&gt; li { display; inline. } &lt;/style&gt; &lt;/head&gt; &lt;link rel="stylesheet" href="divCss.css"&gt; &lt;body&gt; &lt;script&gt; function lurl(page) { let node = document;getElementById('mainContent'); let url = '&lt;object type="text/html" data=' + "\""+ page + "\"" + '&gt;&lt;/object&gt;'. node;innerHTML = url: } &lt;/script&gt; &lt;div id="container"&gt; &lt;div id="Welcome"&gt; &lt;table style="width. 100%"&gt; &lt;tr&gt; &lt;td&gt; &lt;div&gt; &lt;img alt="Hostel" src="hostel1:webp" width="200" height="100"&gt; &lt;/div&gt; &lt;/td&gt; &lt;td align="right"&gt; &lt;div&gt; &lt;h2 style="color; black: font-family; Lucida Calligraphy: font-style; black:"&gt;Welcome to XYZ Hostel&lt;/h2&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div class="topnav"&gt; &lt;ul style="list-style; none: padding-left; 0." &gt; &lt;li&gt;&lt;a class="active" href="#" onclick="lurl('Student_Home.html')"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Student_2.html')"&gt;Login&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Teacher_3.html')"&gt;Room Details&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Marks:html')"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="menuOption"&gt; &lt;;-- Side navigation --&gt; &lt;div class="sidenav"&gt; &lt;ul style="list-style: none. padding-left. 0"&gt; &lt;li&gt;&lt;a class="active" href="#" onclick="lurl('Student_Home.html')"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Student_2.html')"&gt;Login&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Teacher_3:html')"&gt;Room Details&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="lurl('Students_Marks.html')"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="mainContent" class="main"&gt; &lt;!-- iframe id="contentPage" height="600" width="1200" style="border: 0"&gt; &lt;/iframe --&gt; &lt;/div&gt; &lt;footer&gt; Thank you &lt;/footer&gt; &lt;/body&gt; &lt;/html&gt;</pre></div></div><p></p><p> <a href="https://i.stack.imgur.com/VxqHB.png" rel="nofollow noreferrer">在此處輸入圖像描述</a></p></div> 當在eslint中啟用space-before-blocks時,僅強制執行一個空間而不是幾個空間 如何使用 eslint 在塊(塊前的空格)之前強制執行 1 個空格?
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM