2014-07-17 165 views
4

我正在使用jslint。我在我的评论中有这个宽容设置。jslint缺少属性名称

/*jslint todo: true*/ 

在线测试人员通过它。我在前面测试过一段代码。但是,后来我得到这个失败的消息:

Missing property name. 

有谁知道为什么属性名被认为是排在第二位失踪,而不是第一?

更新17/072014 15:03 - 包括代码

我能对这个问题用下面的代码隔离。下面你可以看到代码的部分,如果在lint.com什么错误,在他们的输出运行:

/** 
    * @todo "Unexpected TODO comment". 
    */ 

/*jslint todo: true*/ 
/** 
    * @todo Will be tolerated by jslint. 
    */ 
/*jslint todo: false*/ 

var obj = { 
    /** 
     * @todo "Unexpected TODO comment". 
     */ 
}; 

/*jslint todo: true*/ 
var obj = { 
    /** 
     * @todo jslint will tolerate this line. 
     */ 
}; 
/*jslint todo: false*/ 

var obj = { 
    /*jslint todo: true*/ 
    /** 
     * @todo jslint will never get to this line. 
     */ 
    /*jslint todo: false*/ 
}; 

我发现那是什么耐受性无法对象文本中进行设置。我现在可以解决这个问题。

我很难找到关于这个问题的文档,因为我对'literal'的搜索被字面记法错误所掩盖。有谁知道为什么会出现这种情况,或者有文件解释它,甚至只是说明它发生了?

+0

什么是代码? – ruffin

+0

我现在已经包含了代码和一些附加信息。 – Shoreline

回答

1

当您在对象中引入/* */注释时,JSLint不喜欢它。

例如,我有这个错误与此代码:

config.output = { 
    /*jslint nomen:true*/ 
    path: __dirname + '/public', 
    /*jslint nomen:false*/ 

    publicPath: BUILD ? '/' : 'http://localhost:8080/', 
    filename: BUILD ? '[name].[hash].js' : '[name].bundle.js', 
    chunkFilename: BUILD ? '[name].[hash].js' : '[name].bundle.js' 
}; 

,它是通过改变来解决:

/*jslint nomen:true*/ 
config.output = { 
    path: __dirname + '/public', 
    publicPath: BUILD ? '/' : 'http://localhost:8080/', 
    filename: BUILD ? '[name].[hash].js' : '[name].bundle.js', 
    chunkFilename: BUILD ? '[name].[hash].js' : '[name].bundle.js' 
}; 
/*jslint nomen:false*/ 

我知道它已经有一年或两年既然你问,但,希望这可以帮助任何正在寻找的人。