我正在使用JSHint for Visual Studio.JSHint发出关于我知道可以忽略的问题的警告并不罕见.我一直// ignore jslint在使用相关的行,但我发现我们也可以忽略特定的错误代码.从1.0.0 rc1发行说明:
此版本为JSHint生成的每个警告和错误消息添加唯一的数字代码.这意味着您现在可以忽略JSHint产生的任何警告,即使没有相应的选项.您可以使用特殊的减号( - )运算符来完成此操作.例如,以下是忽略有关尾随小数点的所有消息的方法(W047):
/*jshint -W047*/
看起来很酷,但尽可能尝试,我找不到所有错误代码的列表.Visual Studio的警告列表不提供数字错误代码,只提供错误文本.
当然这个名单出现在某个地方,对吧?我真的花了一个小时谷歌搜索.但到目前为止没有成功.
当我将Twitter Bootstrap与其他第三方JS库一起使用时,我常常遇到这个问题,例如html5.js来自WordPress的"Twenty Twelve"主题,其中构建失败,因为jshint(或者jslint我以前认为TB的先前版本)由于第三个而引发错误-party JS库,例如
\n##################################################
Building Bootstrap...
##################################################\n
js/html5.js: line 3, col 122, Expected ')' to match '(' from line 3 and instead
saw ','.
js/html5.js: line 3, col 140, Expected an identifier and instead saw ')'.
js/html5.js: line 4, col 101, eval is evil.
js/html5.js: line 6, col 369, Confusing use of '!'.
js/html5.js: line 6, col 422, Confusing use of '!'.
js/html5.js: line 7, col 61, 'b' is already defined.
js/theme-customizer.js: line …Run Code Online (Sandbox Code Playgroud) 我有以下内容:
angular.module('test')
.controller('TestMenuController',
[
'$http',
'$scope',
'$resource',
'$state',
'os',
'us',
function (
$http,
$scope,
$resource,
$state,
os,
us) {
Run Code Online (Sandbox Code Playgroud)
当我在VS2014中构建它时,它给出了一条错误消息:
JSHint (r10): 'angular' is not defined.
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何避免这个消息出现吗?
我在哪里可以获得JSHint默认选项的完整列表.我尝试在网上搜索但找不到任何东西.
编辑:我的意思是默认的列表值的所有选项,如果它是不明确的:)
I am playing around with the Facebook's react.js library. I am trying to use their JSX syntax which describes creating a view in the following way.
/** @jsx React.DOM */
var HelloMessage = React.createClass({
render: function() {
return <div>{'Hello ' + this.props.name}</div>;
}
});
React.renderComponent(<HelloMessage name="John" />, mountNode);
Run Code Online (Sandbox Code Playgroud)
JSLint obviously does not like this ("expected an identifier and instead saw ' <';" - JavaScript syntax error), so how do I get around this in my .jshintrc file?
我对这个JSLint错误非常感兴趣.我怎么能忍受呢?它有标志或复选框吗?
当你做以下事情时,你会得到它:
v && arr.push(v);
Run Code Online (Sandbox Code Playgroud)
而不是:
if (v) {
arr.push(v);
}
Run Code Online (Sandbox Code Playgroud)
两者都做同样的事情.如果你把:
window.test = function(v) {
'use strict';
var arr = [];
if (v) {
arr.push(v);
}
return arr;
};
Run Code Online (Sandbox Code Playgroud)
进入minifier它minifies到这个反正:
window.test=function(a){var b=[];a&&b.push(a);return b};
Run Code Online (Sandbox Code Playgroud) CSiginIn,CSignUp,CTryIt,CBlocks是所有功能宣布为
function CSignIn(){//stuff here}
Run Code Online (Sandbox Code Playgroud)
然而JSHint说我错过了'新''前缀'.我该怎么做才能解决这个问题?
它们只是模块模式中的函数.另外,它要求我删除我在功能结束时放置的分号.
var Control = ( function ()
{
/**
*Publik
*/
var publik = function ( page )
{
// page 1 initialization
if( page == 1 )
{
CSignIn();
CSignUp();
CTryIt();
CBlocks();
}
Run Code Online (Sandbox Code Playgroud)
功能示例......
function CTryIt()
{
// pull elements
var tryit_button = document.getElementById( 'tryit_button' );
// initialize access to Model
tryit_button.addEventListener( "click", function( )
{
new AjaxRequest().invoke( 'ajax_type=ControlTryIt',
function( server_response_text )
{
new AjaxResponse( server_response_text, 'page_change' …Run Code Online (Sandbox Code Playgroud) 在Karma测试中,有很多全局变量和函数,JSHint抱怨它(它被集成到我的编辑器中).
如何告诉JSHint忽略这个特定文件中的所有未定义变量?我希望/* jshint undef: false */能够关闭这些警告,但事实并非如此.
我使用Atom的linter,react和linter-jshint/ linter-jsxhint.在我的JSX文件中,我不断收到警告
警告:'import'仅在ES6中可用(使用esnext选项).(W119)
这非常简单.我做了一些搜索,发现这可以在jshintConfig选项中设置package.json(使用NPM时).我的项目使用NPM,我有一个package.json.我补充说:
"jshintConfig": {
"esnext": true
}
Run Code Online (Sandbox Code Playgroud)
之后,我做了重装,但警告仍然存在.我还修改了Atom()中的linter-jshint/ linter-jsxhintconfig config.cson:
"linter-jshint":
harmony: true
esnext: true
"linter-jsxhint":
harmony: true
esnext: true
Run Code Online (Sandbox Code Playgroud)
并做了重装,但也没有帮助.
那么:当使用linter-jshint/ linter-jsxhint作为Atom包时,如何设置esnext选项?
jshint ×10
javascript ×6
jslint ×4
angularjs ×1
atom-editor ×1
build ×1
coding-style ×1
facebook ×1
git ×1
github ×1
jsxhint ×1
makefile ×1
reactjs ×1