JsHint with Ext Js in VisualStudio

2019-08-08 06:11发布

I am working with Ext Js and Visual Studio. With _references.js I can get the intellisense working. I can add a definition for "Ext" in here for JsHint:

enter image description here enter image description here

But it still thows 500 errors about ext-all-debug.js

I am wondering if using JsHint here adds any value to my project. Visual Studio seems to take care of true JavaScript syntax errors.

Some examples of the warnings:

JsHint (W116): Expected '===' and instead saw '=='.

or:

JsHint (W083): Don't make functions within a loop.

Should I disable JSHint completely or try to configure it better?

When a major framework does not respect the rules then why should I?

Update: In web essentials you can create a file called something.weignore. It follows the same syntax than .jshintignore.

Source: http://vswebessentials.com/features/general

1条回答
劫难
2楼-- · 2019-08-08 06:50

You definitely shouldn't be running the linter over ext-all-debug.js. Ignore that using a file called .jshintignore in the root of your project and put the path of ext-all-debug.js in there. An example of the content of .jshintignore could be:

content/js/extjs5.1/ext-debug-all.js
content/js/jquery.js

This would tell jshint to ignore jquery.js and extjs. You can also exclude whole directories. Take a look at the jshint ignore for the jQuery project:

https://github.com/jquery/jquery/blob/master/.jshintignore

external
src/intro.js
src/outro.js
test/data/jquery-1.9.1.js
test/data/badcall.js
test/data/badjson.js
test/data/json_obj.js
test/data/readywaitasset.js
test/data/readywaitloader.js
test/data/support/csp.js
test/data/support/getComputedSupport.js

Maybe Ext JS is working to address those errors internally, maybe they just don't care. But don't let another person's code practises negatively affect your own. If you feel you'll be writing better code by using jshint then use it! There are good reasons behind the warnings you are seeing.

查看更多
登录 后发表回答