在现有的GRUNT项目(http://gruntjs.com/getting-started)中,我执行了npm install然后grunt,我收到了大量的JSHint错误(缺少分号,混合空格和制表符,额外的逗号等)。我知道该项目正在开发一个不同的系统。
错误说明:
Running "jshint:beforeconcat" (jshint) task
Linting js/filters/empFilter.js...ERROR
[L22:C4] Missing semicolon.
}])
带有错误的angularjs文件
angular.module ("app").filter('empFilter', [function () {
return function (emps, username) {
/*some code*/
return emps;
};
}]) /* <--- error at this line */
的package.json
{
"name": "test_app",
"version": "0.0.11",
"path": "http://127.0.0.1/TestApp/",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-autoprefixer": "~0.1.20130516",
"grunt-contrib-concat": "~0.1.2",
"grunt-contrib-uglify": "~0.1.1",
"grunt-contrib-cssmin": "~0.4.0",
"grunt-contrib-copy": "~0.4.0",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-yuidoc": "~0.4.0",
"grunt-karma": "~0.4.4",
"grunt-open": "~0.2.0",
"grunt-bumpx": "~0.1.0",
"autoprefixer": "~0.4.20130515",
"grunt-git": "0.0.1",
"grunt-devtools": "0.1.0-7"
}
}
gruntFile.js中的JSHint选项
jshint: {
options: {
"globals": {
"asi": false,
"ga": true,
"FileReader": true,
"html2canvas": true,
"console": true,
"angular": true,
"$": true,
"window": true,
"screen": true,
"Image": true,
"clearTimeout": true,
"setTimeout": true,
"document": true,
"localStorage": true,
"sessionStorage": true,
"device": true,
"navigator": true,
"io": true,
"createjs": true,
"lib": true,
"platform": true,
"inherits": true,
"signals": true,
"Date": true
}
}
我不想根据错误更新文件,因为项目在另一个系统上运行正常。我在这里错过了什么吗?
答案 0 :(得分:3)
也许其他系统有一个.jshintrc
文件,里面有宽松的linting选项,也许这个文件没有添加到源代码控制中。