问题
I am using angular and would like to use JSHint. However, I get a lot of warnings like '$' is not defined.
, which would be correct in angular but JSHint does not know this.
Is there a way to ignore some certain errors (as this $-error occurs rather often) or is there a better linter for the JS of angular?
回答1:
JsHint allows you define globals variables across your source code and a per file basis.
You can add a .jshintrc file and put the following snippet which will effect your entire code
{"predef": [ "$" ]}
A second option is to add
/* global $ */
as a comment at the top of offending files.
See http://jshint.com/docs/#inline-configuration
Over all, I prefer eslint. It has functional parity with jshint, but also has the advantage of being very extensible. There are many existing eslint packages out there for handling angular specific linting errors and you have the option of writing your own rules
来源:https://stackoverflow.com/questions/35605626/using-jshint-with-angular-ignore-angular-styles