首页 技术 正文
技术 2022年11月17日
0 收藏 911 点赞 3,980 浏览 1131 个字

原文链接:  

  http://www.jameswiseman.com/blog/2011/03/26/coding-convention-an-style-guide/

  http://www.jameswiseman.com/blog/2011/01/17/jslint-a-guide-to-jslint-messages/

The Messages

  Expected ‘{a}’ at column {b}, not column {c}.

  这是一个简单的代码错误缩进例子,可以通过下面代码片段来看这个最简单的事例。

var a = 0;
var b = 0; //Problem at line 2 character 3: Expected 'var' ar column 1, not column 3

  

  Expected ‘{a}’ to have an indentation of {b} instead of {c}.

  这是另一个缩进的问题,默认的缩进step是4,意味着缩进列应该从位置开始1, 5, 9, 13, 17, etc.

  下面的例子使用了5个空格的缩进,作为一个新行的开始位置就将会是字符6(character 6),正如提示信息所表示的意思。

function MyFunc() {
alert('hello'); //Problme at line 2 character 6: Expected 'alert' at column 5, not column 6.
//
}

  

  Expected exactly one space between ‘{a}’ and ‘{b}’.

  这条提示是JSLint对于花括号正确位置的要求,如下的代码片段在JSLint中执行就会产生这样的提示。

if (x === 0)
{ //brace on the next line
alert("hello");
}

  即使你已经将花括号放置在了正确的位置(与if同一行),JSLint还是需要你使用正确的空格。所以,下面的代码片段一样也会产生这个提示信息:

if (x === 0){ // no spaces
alert('hello');
}if(x === 0) { // two spaces
alert('hello');
}

  Missing spaces and tabs.

  这个提示信息是因为在一行的缩进是空格和tabs的混合。大部分的IDES(集成开发环境)都会有一个将tabs自动转换为空格的选项,建议你开启这个选项。

  Unexpected space between ‘{a}’ and ‘{b}’

  该提示信息是因为在不需要空格的地方使用了空格,下面的这段代码段就将会产生这个提示信息:

  

if ( x === 0){ // Unexpected space between '(' and 'x'
alert('hello');
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,556
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898