在win7上,我安装了Cygwin,并通过
npm install -g jslint
通过在中配置.vimrc,节点-jslint将成为我的Javascript语法检查器:
let g:syntastic_js_checkers=['jslint']
我有一个只有一行代码的文件test.js:
function(){console.log('hello')}
在cmd.exe中运行jslint test.js时,我得到:
test.js
#1 Expected exactly one space between 'function' and &
是否可以在一个或多个.js文件上运行JSLint,方法是在chrome或firefox中从调试/开发人员控制台加载JSLint?
我想这样做的原因是,我想在console.log()中打印JSON中JSLint的解析,它在文档中写道:
// You can obtain the parse tree that JSLint constructed while parsing. The
// latest tree is kept in JSLINT.tree. A nice stringication can be produced
// with
// JSON.stringify(
编辑: Syntastic配置为使用JSLint
EDIT2:我使用的是JavascriptLint,而不是JSLint
在下面的代码中,syntastic警告function inside does not always return a value
function(){
switch(age){
case 1:
return 'won';
case 2:
return 'too';
case 3:
return 'tree';
default:
throw 'wow man, you are old!
最新版本的aws-amplify与npm一起安装。此外,npm init是使用入口点文件'entryPoint.js‘运行的。但是,当我输入entryPoint.js并将这些代码行粘贴到顶部时,
import Amplify, {Auth} from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
我收到一条JSLint错误消息,内容为:
Expected an identifier and instead saw 'impor
我想从命令提示符运行jsLint。在稍后的阶段,作为ANT构建中的一个任务。
我下载了rhino 1.7 R3和最新的jslint.js,并编写了这个自定义的test.js,其内容是:
for (var i = 0; i < 10; i++) { }
请注意,这一行代码应该已经导致jslint发出警告:
Move 'var' declarations to the top of the function.
我使用了这个命令:
java -jar .\rhino1_7R3\js.jar .\douglascrockford-JSLint-e31fa4c\jslint.js
目前,我正在努力改进构建web应用程序的工作流程。安装了Yeoman之后,命令"grunt“为我提供了一种组合和缩小javascript文件的好方法。我的main.js文件是从许多coffeescript文件中生成的,这是我以前手动做的。由于文件依赖关系,我不使用编译coffeescript的集成方法。(这样可以)
,但问题是:当我现在试图运行"grunt“时,会从生成的js文件中产生"lint”错误,如下所示:
line 3 col 3 Missing "use strict" statement.
line 3 col 3 Exp
我在一个项目上运行,我碰到了这个错误:
期望}和else之间正好有一个空间
在这段代码中:
// Check for the existance of the file created by firstrun.js
if (runOnce.exists) {
window.location = 'app:/core/firstrun.html';
}
// Check for version info
else if (!versionInfo.exists) {
window.location = 'app:/core/createVersi
这是我当前的语法配置:
let g:syntastic_check_on_open=1
let g:syntastic_quiet_messages = { "level": [] }
let g:syntastic_aggregate_errors = 1
let g:syntastic_javascript_checkers = ['jshint', 'jslint']
let g:syntastic_warning_symbol = 'WW'
let g:syntastic_error_symbol = 'EE
我使用的是GNU Make 3.81,在我的Makefile中有以下规则:
jslint :
java org.mozilla.javascript.tools.shell.Main jslint.js mango.js \
| sed 's/Lint at line \([0-9]\+\) character \([0-9]\+\)/mango.js:\1:\2/'
如果我直接在命令行中输入,则可以很好地工作,但是如果我使用"make jslint“运行正则表达式,则它不匹配。但是,如果我在Makefile中用\{1,\}替换\+,它就可以工作:
js
Unexpected 'typeof'. Use '===' to compare directly with undefined.
if (typeof exports !== 'undefined') {
这是来自backbone.js的代码。
它似乎不喜欢它的语法。
如何更改此代码才能让jslint.com满意?