jshint 了解 Angular 吗? [英] Does jshint understand Angular?

查看:22
本文介绍了jshint 了解 Angular 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jshint 在定义 Angular 样式指南(由 John爸爸托德格言).例如,对于这样的控制器:

jshint is throwing an error when defining an angular module (or directive, or factory) as recommended by the Angular style guides (by John Papa or Todd Motto). For example, for a controller like this:

(function () {
    'use strict';

    angular
        .module('myApp')
        .controller('myAppCtrl', theController);

    function theController() {...}

})();

... jshint 抛出这个错误:

... jshint throws this error:

'theController' was used before it was defined.

尽管存在这些错误,Angular 应用程序仍能完美运行.但是我不知道为什么 jshint 抗议...

The angular app works perfectly despite these errors. However I don't know why jshint protests...

我错过了什么?我想知道 jshint 是否是 angular 代码质量的一个很好的评估器(尽管它包含在流行的包中作为 generator-angular)还是我做错了什么(尽管我的应用程序有效).

What am I missing? I wonder if jshint is a good evaluator of the quality of the angular code (despite it is included with popular packages as generator-angular) or it's me that I am doing something wrong (although my app works).

提前致谢!

推荐答案

使用 latedef 属性并将其设置为 false.这允许提升功能,IMO 很好.但仍然报告吊装 vars,这是不好的 IMO

Use the latedef property and set it to false. This allows hoisting of functions, which IMO is fine. But still reports hoisting of vars, which is bad IMO

这篇关于jshint 了解 Angular 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆