Using JsHint with Angular, ignore angular styles

2019-08-12 22:14发布

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条回答
相关推荐>>
2楼-- · 2019-08-12 22:37

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

查看更多
登录 后发表回答