JSLint for eclipse 安裝以及setting 說明

來源:互聯網
上載者:User

JSLint is a JavaScript program that looks for problems in JavaScript programs. It is acode quality tool

how to use JSLintfor  Eclipse

Installation

Step One:Open Eclipse up on your machine and go to‘Help’ -> ‘Install New Software’


Step Two: Click ‘add’ on the popup and youwill have the screen as below. 

With that screen where it says location add the following link:

https://svn.codespot.com/a/eclipselabs.org/mobile-web-development-with-

phonegap/tags/jslint4java1/download 

then click ‘ok’.




Step Three: Once the information has loadedchoose the options as shown

 on the next screen below selecting ‘jslint4java’

 and click next. If have not install ‘Javascript Development Tools’, selected it too.



Step Four: Keep clicking next, you may have toaccept any license terms 

and during installation you will get the screen

 below,don’t worry, just click ‘ok’.


StepFive: OpenEclipseup on your machine and go to‘window’->‘preferences’,

click the item ‘jslint4java’

Checked some checkbox and input forsetting 




StepFix: choosea project ,clicktheenablejslint4java,check the eclipse head  menu, 

clickproject ->clean… ,then click project->Build project . 

If you have many builder, you can chooseonly one builder by 

right click projectname ->  properties ->Builders


If you only need one builder ,you canedit the .project file of one project

Edit the file content as follow 

<?xml version="1.0" encoding="UTF-8"?><projectDescription><name>mr</name><comment></comment><projects></projects><buildSpec><buildCommand><name>com.googlecode.jslint4java.eclipse.jsLintBuilder</name><arguments></arguments></buildCommand></buildSpec><natures><nature>com.googlecode.jslint4java.eclipse.jsLintNature</nature></natures></projectDescription>


JSLint Setting

Filter code

describe

other

adsafe

If adsafe rules should be enforced

是否Verify第三方的JS庫Adsafe。

bitwise

If bitwise operators should be allowed

如果為真,SHint會禁用位元運算符 Javascript允許位元運算,但是他卻沒有整型,位元運算符要把參與運算的數字從浮點數變為整數,並在運算後再轉換回來。這樣他們的效率就不如在別的語言中那麼高。

browser

If the standard browser globals should be predefined

是否標準的瀏覽器全域變數應該預先定義。

cap

If upper case html should be allowed

是否允許大寫html標籤。

confusion

If types can be used inconsistently

是否變數使用類型一致。

continue

If the continuation statement should be tolerated

是否允許連續的聲明。

css

If css workarounds should be tolerated

是否允許Css域。

debug

If debugger statements should be allowed

是否允許調試器聲明。

devel

If logging should be allowed (console, alert, etc.)

是否允許調試js。

eqeqeq

If === should be allowed

如果為真,JSLint會看你在代碼中是否都用了===或者是!==,而不是使用==和!=。


Filter code

describe

other

es5

If es5 syntax should be allowed

是否允許ECMAScript 5文法

evil

If eval should be allowed

如果為真,JSLint會允許使用eval eval提供了訪問Javascript編譯器的途徑,這有時很有用,但是同時也對你的代碼形成了注入攻擊的危險,並且會對debug造成一些困難。 記住,Function建構函式也是另一個‘eval’,另外,當傳入的參數是字串的時候,setTimeout和setInterval也會類似於eval。

forin

If for in statements need not filter

如果為真,那麼,JSHint允許在for in 迴圈裡面不出現hasOwnProperty, for in迴圈一般用來遍曆一個對象的屬性,這其中也包括他繼承自原型鏈的屬性,而hasOwnProperty可以來判斷一個屬性是否是對象本身的屬性而不是繼承得來的。

immed

If immediate invocations must be wrapped  in parens

如果為真,JSLint要求匿名函數的調用如下:

(function(){ // }());而不是

(function(){ //bla bla })();

laxbreak

if statement breaks should not be checked

如果為真,JSLint則不會檢查換行。 Javascript會通過自動補充分號來修正一些錯誤,因此這個選項可以檢查一些潛在的問題。

newcap

If constructor names capitalization is ignored

如果為真,JSLint會要求每一個建構函式名都要大寫字母開頭。


Filter code

describe

other

nomen

If names may have dangling _

如果為真,JSHint會禁用底線的變數名。 很多人使用_name的方式來命名他們的變數,以說明這是一個私人變數,但實際上,並不是,底線只是做了一個標識。 如果要使用私人變數,可以使用閉包來實現。

on

If html event handlers should be allowed

是否允許html事件處理常式。

onevar

if only one var statement per function is allowed.

如果為真,JSLint期望函數只被var的形式聲明一遍。

passfail

If the scan should stop on first error

如果為真,JSHint會在發現首個錯誤後停止檢查。

plusplus

If increment/decrement should be allowed

如果為真,JSHint會禁用自增運算和自減運算 ++和--可能會帶來一些代碼的閱讀上的困惑。

regexp

If the . should be allowed in regexp literals

如果為真,JSHint會不允許使用.和[^...]的正則, 因為這樣的正則往往會匹配到你不期望的內容,並可能會應用造成一些危害。

rhino

If the rhino environment globals should be predefined

是否Rhino的環境全域變數應該預先定義。

safe

If use of some browser features should be restricted

如果使用一些瀏覽器特性應該被限制。

strict

If the 'use strict'; pragma is optional

如果為真,JSHint會要求你使用use strict;文法。 Strict 模式是ES5裡面的一個新特性,他允許你把一個程式或者函數放在一個“嚴格”的範圍中。ECMAScript 5


Other setting

describe

the mumber of spaces used for indentation

規定代碼之間的空格數

The maximum number  of warnings reported

最大顯示錯誤數

Maximum line length

每行最大字元數

The names of predefined global variables

預先定義的全域變數


references


Jlint 官網 http://www.jslint.com/lint.html

google 代碼規範 http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml

jquery 代碼規範http://contribute.jquery.org/style-guide/js/



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.