Tag: jshint

与Grunt同时运行`watch`&`nodemon`

我刚刚开始使用Grunt,并希望运行grunt-contrib-watch [GitHub页面]在每次修改文件时使用我的JavaScript(使用grunt-contrib-jshint [GitHub页面] )并运行grunt-nodemon [ GitHub页面] ,同时使用grunt-concurrent [GitHub页面] 。 据我所知(我显然不)我的Gruntfile应该: 默认运行concurrent concurrent运行watch 每次修改文件时, watch都会运行jshint Gruntfile.js module.exports = function (grunt) { grunt.initConfig({ concurrent: { dev: [ 'watch' ], options: { logConcurrentOutput: true } }, jshint: { server: [ '**/*.js', '!node_modules/**/*.js' ], options: { node: true } }, watch: { all: [ '**/*/.js', '!node_modules/**/*.js' ], tasks: [ […]

在Windows中不能使用GLOB和JSHint?

我正在做NPM的PoC作为构build工具( http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/ )。 我是相当新的使用NPM。 现在,我只安装了JSHint和Mocha。 我的packagae.json被附上。 现在,当我在命令行(Windows 7)中运行“npm run lint”时,它给我一个错误: c:\project>npm run list MyNPMProject@1.0.0 lint c:\project jshint test/*.js 错误:无法打开testing/ *。js 当我更改脚本“lint”:“jshint test / test.js”时,它可以工作。 我可以用jshint使用glob吗? 请提前告知并感谢您。

jshint错误:重新定义'$'

我有一个Node.js Web应用程序,我使用Backbone.js和jQuery。 我的主要js文件是app.js ,其中包括所有必需的脚本,包括jQuery。 所以,这是我的app.js代码的开始: 'use strict'; var _ = require('lodash'); var $ = require('jquery'); var B = require('backbone'); B.$ = $; 现在,如果我在我的项目上运行grunt ,它会在jQuery加载到$的行上引发错误。 它显示了我: Linting public/js/app.js …ERROR [L4:C5] W079: Redefinition of '$'. var $ = require('jquery'); 我仍然可以使用grunt –force运行所有的东西,但是我想要消除这个错误。 有人可以解释为什么会引发错误,以及如何解决? 我的.jshintrc文件: { "laxcomma": true ,"laxbreak": true ,"curly": true ,"eqeqeq": true ,"immed": true ,"latedef": true ,"newcap": […]

沉默时JSHint具体

考虑下面的标准Expressfunction: if (app.get('env') === 'development') { app.use(function (err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: err }); }); } 显示以下警告: “下一个”被定义,但从未使用过。 – W098 我知道我可以禁用所有的警告 ,但这不是我想要的。 我需要的是只沉默JSHint一个特定的参数(上面的代码片段中的“下一个”)。 对于这个看似普遍的问题,我还没有看到明确的答案。 有任何想法吗? 谢谢!

抑制`预期的标识符,而是看到'默认'(一个保留字)在JSLint与Mongoose

我正在使用jshint来validation我的JavaScript文件。 在服务器端,我使用Mongoose的node.js。 在Mongoose中,我被鼓励以如下的方式写图式: var UserSchema = new mongoose.Schema({ firstname : { type: String, default: '' } }); 运行linting时,出现错误: Expected an identifier and instead saw 'default' (a reserved word). 有没有办法来压制这个错误? 我真的更喜欢这种行为,而不是写作: var UserSchema = new mongoose.Schema({ firstname : { type: String, "default": '' } });

grunt-contrib-jshint警告:path必须是string;

我一直在试图使用jshint grunt模块来validation我的代码,但我总是得到以下错误: Running "jshint" task [D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js Running "jshint:all" (jshint) task [D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js Verifying property jshint.all exists in config…OK Files: Gruntfile.js, app/scripts/app.js Options: force=false, reporterOutput=null, jshintrc=".jshintrc", reporter={} Warning: Path must be a string. Received { toString: [Function], reporter: [Function] } Use –force to continue. 问题是即使使用–verbose和-debug,它不显示任何工作的错误,只是“path必须是一个string”,我用JSLint(使用括号)validation文件,它工作得很好,网站也工作正常。 […]

jshint:使用节点选项,但不允许控制台语句?

我正在使用jshint,我想使用node选项,但我也想禁止控制台语句。 这可能吗? 我一直在阅读jshint选项文件没有运气。 我试过的东西都失败了: "node": true, "globals": { "console": false } 也: "node": true, "devel": false 我想我可以设置"node": false ,然后明确地将所有内容添加到globals ,但这看起来很丑。

使用JSHint和Express.js /'delete'(保留字)

我正在使用Node.js的Express.js ontop来创buildRESTful API,并使用grunt来监视我的文件并自动将我的JavaScript删除。 每次使用删除function,它都会被JSHint标记: [L218:C9] Expected an identifier and instead saw 'delete' (a reserved word). app.delete('/api/users/:userid', function deleteUser(req, res, next) { 我明白'删除'是一个保留字,但它是由Express.jsselect的! 有没有更好的方式去linding我的Express.js应用程序? 任何方式来closures这个检查?

在命令行上运行cmd时,npm运行cmd失败

在我的HTTP状态检查项目中 : 如果我运行node_modules/.bin/jshint . 我得到: $ node_modules/.bin/jshint . test/inAdapters_fileAdapter.js: line 73, col 31, Missing semicolon. 1 error 它正确执行并产生预期的输出:1错误。 但是,如果我将这个命令添加到package.json中,并尝试通过npm run那么它将起作用并产生预期的输出,但是也会出现一些错误: $ npm run jshint > http-status-check@0.0.5 jshint /home/guy/source/http-status-check > jshint . test/inAdapters_fileAdapter.js: line 73, col 31, Missing semicolon. 1 error npm ERR! Linux 3.13.0-24-generic npm ERR! argv "node" "/home/guy/local/bin/npm" "run" "jshint" npm ERR! node v0.10.31 […]

我如何使jshint缩进选项的工作

jslint可以通过运行'jslint –indent 4 test.js'来检查缩进,但我不明白它在jshint中的工作。 我按照以下步骤来做。 通过“npm install -g jshint”安装jshint 编辑〜/ .jshintrc,我的jshintrc看起来像 {…,“indent”:4,“white”:false,…} 编辑js文件test.js / jshint缩进:4 / var condition,doSth; 如果(条件) doSth(); //预计是无效的 运行jshint test.js,但缩进检查不起作用。 开始的两个空格可以通过检查。