[TypeScript] vs code TSLint常见错误解决方案

TSLint是一个Typescrip{过滤}t验证工具,用于检测代码。


TSLint: comment must start with a space (comment-format)

注释必须从一个空格开始(comment-format)

也就是说//之后必须跟随一个空格。

“Missing semicolon.” : “缺少分号.”,
“Use the function form of \”use strict\”.” : “使用标准化定义function.”,
“Unexpected space after ‘-’.” : “在’-'后面不应出现空格.”,
“Expected a JSON value.” : “请传入一个json的值.”,
“Mixed spaces and tabs.”: “空格和TAB重复.”,
“Unsafe character.” : “不安全的字符.”,
“Line too long.”: “本行中的字符超过设定的最大长度.”,
“Trailing whitespace.”: “本行末尾有过多无用空格.”,
“scrip{过滤}t URL.” : “脚本URL.”,
“Unexpected {a} in ‘{b}’.” : “在 ‘{b}’ 中不该出现 {a}.”,
“Unexpected ‘{a}’.” : “不该在此出现’{a}’.”,
“Strings must use doublequote.” : “字符串需要用双引号”,
“Unnecessary escapement.” : “不需要转义”,
“Control character in string: {a}.” : “在字符串中出现了Control的字符”,
“Avoid \\’.” : “避免 \\”,
“Avoid \\v.” : “避免 \\v”,
“Avoid \\x-.” : “避免 \\x-”,
“Bad escapement.” : “错误的转义字符”,
“Bad number ‘{a}’.” : “错误的数字 ‘{a}’”,
“Missing space after ‘{a}’.” : “在’{a}’之后缺少空格”,
“Don’t use extra leading zeros ‘{a}’.” : “不要再’{a}’的前面用多余的0″,
“Avoid 0x-. ‘{a}’.” : “避免使用 0x-. ‘{a}’.”,
“A trailing decimal point can be confused with a dot ‘{a}’.” : “在’{a}’中使用点尾随小数点”,
“Unexpected comment.” : “不该在此处出现注释”,
“Unescaped ‘{a}’.” : “没有转义 ‘{a}’”,
“Unexpected control character in regular expression.” : “在正则表达式中出现了control字符”,
“Unexpected escaped character ‘{a}’ in regular expression.” : “在正则表达式中出现了没有转义的字符 ‘{a}’”,
“Expected ‘{a}’ and instead saw ‘{b}’.” : “应该用 ‘{a}’代替’{b}’”,
“Spaces are hard to count. Use {{a}}.” : “空格难以统计,请使用 {{a}}”,
“Insecure ‘{a}’.” : “不安全的 ‘{a}’”,
“Empty class.” : “空的class”,
“Expected a number and instead saw ‘{a}’.”:“应该用数字代替’{a}’”,
“‘{a}’ should not be greater than ‘{b}’.”:“‘{a}’不应该比’{b}’大”,
“‘hasOwnProperty’ is a really bad name.”: “‘hasOwnProperty’是关键字”,
“‘{a}’ was used before it was defined.”:“‘{a}’未定义就已经使用了.”,
“‘{a}’ is already defined.”:“‘{a}’被重复定义”,
“A dot following a number can be confused with a decimal point.”:“数字后面的一个点会被误认为是十进制的小数点”,
“Confusing minusses” : “容易混淆的负数表达-”,
“Confusing plusses.” : “容易混淆的正数表达+”,
“Unmatched ‘{a}’.” : “无法匹配的’{a}’”,
“Expected ‘{a}’ to match ‘{b}’ from line {c} and instead saw ‘{d}’.”:“在行{c}中需要用’{a}’和’{b}’匹配,用来代替’{d}’”,
“Unexpected early end of program.”:“程序不可预期的提前终止”,
“A leading decimal point can be confused with a dot: ‘.{a}’.”:“‘{a}’前的点容易混淆成小数点”,
“Use the array literal notation [].”:“使用数组的符号 []“,
“Expected an operator and instead saw ‘{a}’.”:“需要用一个符号来代替’{a}’”,
“Unexpected space after ‘{a}’.”:“在’{a}’之后不能出现空格”,
“Unexpected space before ‘{a}’.”:“在’{a}’之前不能出现空格”,
“Bad line breaking before ‘{a}’.”:“在’{a}’之前错误的换行”,
“Expected ‘{a}’ to have an indentation at {b} instead at {c}.”:“‘{a}’需要在{c}而不是{b}处缩进”,
“Line breaking error ‘{a}’.”:“换行错误 ‘{a}’”,
“Unexpected use of ‘{a}’.”:“此处不能用’{a}’”,
“Bad operand.”:“错误的操作数”,
“Use the isNaN function to compare with NaN.”:“使用isNaN来与NaN比较”,
“Confusing use of ‘{a}’.”:“容易混淆的’{a}’的使用”,
“Read only.”:“只读的属性”,
“‘{a}’ is a function.”:“‘{a}’是一个函数”,
‘Bad assignment.’:“错误的赋值”,
“Do not assign to the exception parameter.”:“不要给额外的参数赋值”,
“Expected an identifier in an assignment and instead saw a function invocation.”:“在赋值的语句中需要有一个标识符,而不是一个方法的调用”,
“Expected an identifier and instead saw ‘{a}’ (a reserved word).”:“需要有一个标识符,而不是’{a}’(保留字符)”,
“Missing name in function declaration.”:“在方法声明中缺少名称”,
“Expected an identifier and instead saw ‘{a}’.”:“需要有一个标识符,而不是’{a}’”,
“Inner functions should be listed at the top of the outer function.”:“内部函数的声明应该放在此函数的顶部。”,
“Unreachable ‘{a}’ after ‘{b}’.”:“在’{b}’之后无法获取’{a}’”,
“Unnecessary semicolon.”:“不必要的分号”,
“Label ‘{a}’ on {b} statement.”:“将’{a}’放在{b}的声明中”,
“Label ‘{a}’ looks like a javascrip{过滤}t url.”:“‘{a}’看上去像一个js的链接”,
“Expected an assignment or function call and instead saw an expression”:“需要一个赋值或者一个函数调用,而不是一个表达式.”,
“Do not use ‘new’ for side effects.”:“不要用’new’语句.”,
“Unnecessary \”use strict\”.”:“不必要的\”use strict\”.”,
“Missing \”use strict\” statement.”:“缺少\”use strict\”的声明”,
“Empty block.”:“空的模块”,
“Unexpected /*member ‘{a}’.”:“不应出现 /*元素 ‘{a}’.”,
“‘{a}’ is a statement label.”:“‘{a}’是一个声明”,
“‘{a}’ used out of scope.”:“‘{a}’使用超出范围”,
“‘{a}’ is not allowed.”:“不允许使用’{a}’”,
“‘{a}’ is not defined.”:“‘{a}’没有被定义”,
“Use ‘{a}’ to compare with ‘{b}’.”:“使用’{a}’与’{b}’相比”,
“Variables should not be deleted.”:“变量需要被删除”,
“Use the object literal notation {}.”:“使用对象的文字符号 {}”,
“Do not use {a} as a constructor.”:“不要使用{a}作为一个构造对象”,
“The Function constructor is eval.”:“The Function constructor is eval.”,
“A constructor name should start with an uppercase letter.”:“一个构造对象的名称必须用大写字母开头.”,
“Bad constructor.”:“错误的构造对象”,
“Weird construction. Delete ‘new’.”:“构造对象有误,请删除’new’”,
“Missing ‘()’ invoking a constructor.”:“缺少括号()”,
“Avoid arguments.{a}.”:“避免参数.{a}.”,
“document.write can be a form of eval.”:“document.write是eval的一种形式”,
‘eval is evil.’:“尽量不要使用eval”,
“Math is not a function.”:“Math不是一个函数”,
“Missing ‘new’ prefix when invoking a constructor.”:“此处缺少了’new’”,
“Missing radix parameter.”:“缺少参数”,
“Implied eval is evil. Pass a function instead of a string.”:“传递一个函数,而不是一个字符串”,
“Bad invocation.”:“错误的调用”,
“['{a}'] is better written in dot notation.”:“['{a}']最好用点.的方式”,
“Extra comma.”:“多余的逗号”,
“Don’t make functions within a loop.”:“不要用循环的方式创建函数”,
“Unexpected parameter ‘{a}’ in get {b} function.”:“在{b}方法中不该用到参数’{a}’”,
“Duplicate member ‘{a}’.”:“重复的’{a}’”,
“Expected to see a statement and instead saw a block.”:“此处应该是语句声明.”,
“Too many var statements.”:“过多var的声明”,
“Redefinition of ‘{a}’.”:“‘{a}’被重复定义”,
“It is not necessary to initialize ‘{a}’ to ‘undefined’.”:“无需将’{a}’初始化为’undefined’”,
“Expected a conditional expression and instead saw an assignment.”:“此处需要一个表达式,而不是赋值语句”,
“Expected a ‘break’ statement before ‘case’.”:“在’case’之前需要有’break’.”,
“Expected a ‘break’ statement before ‘default’.”:“在’default’之前需要有’break’.”,
“This ‘switch’ should be an ‘if’.”:“此处’switch’应该是’if’.”,
“All ‘debugger’ statements should be removed.”:“请删除’debugger’的语句”,
“‘{a}’ is not a statement label.”:“‘{a}’不是一个声明标签.”,
“Expected an assignment or function call and instead saw an expression.”:“需要一个语句或者一个函数调用,而不是一个表达式”,
“Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.”:“函数的声明不能放在类似if的块中,需要放在外部函数的顶部.”


针对自己项目中遇到的一些提示,做一些举例说明:

1 [W099]:Mixed spaces and tabs

这个错误是最常见的,意思是在同一行中,空格和Tab缩进混合使用了,修改很简单,一般是删除Tab缩进,全部改为空格。为了方便,我们可以把编辑器的Tab缩进设置成2个或4个空格,来代替原有的缩进。

2 [W030]:Expected an assignment or function call and instead saw an expression

这个错误提示的很诡异,我是用如下代码提示的这个错误 index-1 <0 ? index = 0:index = index - 1;  这是一个逗号表达式,但是JSLInt认为这里不应该用表达式,而必须是一个函数,所以,如果非常在乎这个错误,就改为if else 语句吧

3 [W041]:Use '===' to compare with ...

这个错误是说,我们要是用全等来代替等于,如果表达式两边的数据类型是一致的话,建议使用全等来判断

4 [W033]:Missing semicolon

缺少分号;这个一般都是自己忘记写了吧,但是有一个需要注意的是,对于只有一句的结构,后面也需要写分号。例如:if(index<0) {index=tcount-1} 这句代码,正确写法是if(index<0) {index=tcount-1;},我是经常忘记这里写分号,汗...

其他还有一些错误提示就对照一下改吧,要培养自己良好的代码风格和书写习惯。

 

原文链接:https://www.itsvse.com/thread-5178-1-1.html

转载于:https://www.cnblogs.com/changfeng1800/p/10986005.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/462390.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ios开发笔记之 线程间通信

performSelectorOnMainThread:selector:waitUntilDone: 用于线程间通信 使两个线程同步或者时异步执行。 block阻塞转载于:https://www.cnblogs.com/vincent-lu/archive/2011/11/29/2267974.html

SQL Cookbook—数字、日期

1、计算不包含最大值和最小值的均值2、把字母数字串转换为数值3、更改累计和中的值–显示存款或取款后的值4、加减日、月、年5、计算两个日期之间的天数6、确定两个日期之间的工作日数目表EMP中&#xff0c;计算BLAKE和JONES的hiredate&#xff08;聘用日期&#xff09;之间的工…

file_table.c 文件分析 linux1_0\linux\fs\file_table.c

/** linux/fs/file_table.c** Copyright (C) 1991, 1992 Linus Torvalds*/#include <linux/fs.h> #include <linux/string.h> #include <linux/mm.h>struct file * first_file; //开头文件. int nr_files 0; //文件位置为0//文件双向链表插入文…

Day 16 包 json模块和os模块

目录 包什么是包包被导入时发生的三件事包和模块的区别相对路径和绝对路径json模块OS模块列出目录下所有文件重命名文件删除文件拼接路径判断是否为文件判断是否为文件夹判断文件是否存在新建文件夹包 什么是包 包就是里一个文件夹,里面存放了多个模块,并且包会自带__init__.py…

人的左右脑

右脑支配左手、左脚、左耳等人体的左半身神经和感觉&#xff0c;而左脑支配右半身的神经和感觉&#xff0c;正如实验一所表明的&#xff0c;右视野同左脑&#xff0c;左视野同右脑相连。因为语言中枢在左脑&#xff0c;所以左脑主要完成语言的、逻辑的、分析的、代数的思考认识…

DevExpress控件使用经验总结

DevExpress控件使用经验总结 DevExpress是一个比较有名的界面控件套件&#xff0c;提供了一系列的界面控件套件的DotNet界面控件。本文主要介绍我在使用DevExpress控件过程中&#xff0c;遇到或者发现的一些问题解决方案&#xff0c;或者也可以所示一些小的经验总结。总体来讲&…

struct task_struct 结构分析 \linux-1.0\linux\include\linux\sched.h

//任务机构体&#xff0c;大小大概1024字节 struct task_struct {/* these are hardcoded - dont touch */ //硬件代码 不可被修改volatile long state; //状态标志 /* -1 unrunnable, 0 runnable, >0 stopped */ long counter; //计数long priority; //…

mysql基础14(关于mysql数据库在没有主键情况下去除重复数据办法)

关于mysql数据库在没有主键情况下去除重复数据办法 约定 表名:mat 根据 cat 字段去重 新增加主键为 id 步骤 1、为mat新增一列自增主键 alter table mat add column id int(11) PRIMARY KEY AUTO_INCREMENT; 2、根据cat字段分组&#xff0c;找到数量大于1的&#xff0c;…

ctype.h,ctype.c 结构分析 \linux-1.0\linux\include\linux\ctype

\linux-1.0\linux\include\linux\ctype.h #ifndef _LINUX_CTYPE_H #define _LINUX_CTYPE_H#define _U 0x01 /* upper */ //大写字母 #define _L 0x02 /* lower */ //小写字母 #define _D 0x04 /* digit */ //数字 #define _C 0x08 /* cntrl */ //控制按键 #define _P 0x10 …

AaronYang WCF教程目录

原创&#xff0c;讲究实践 1. 那天有个小孩教我WCF[一][1/3] 基本搭建 阅读 2013年6月27日1:29:02 2. 那天有个小孩教我WCF[一][2/3] 基本竣工 阅读 2013年6月29日01:30:22 3. 那天有个小孩教我WCF[一][3/3] 第二种代理引用服务&#xff0c;小…

plsql中文乱码 显示问号

输入sql语句select * from V$NLS_PARAMETERS查看字符集&#xff0c;查看第一行value值是否为简体中文 解决方案&#xff1a; 新增环境变量 变量名&#xff1a; NLS_LANG 变量值: SIMPLIFIED CHINESE_CHINA.ZHS16GBK 重启PL/SQL 解决 转载于:https://www.cnblogs.com/tonyzt/p/1…

第二阶段团队绩效评分

第二阶段评分结果&#xff1a; 转载于:https://www.cnblogs.com/xczd/p/11068692.html

从最大似然到EM算法浅解(转载)

http://blog.csdn.net/zouxy09/article/details/8537620#comments转载于:https://www.cnblogs.com/zhihaowang/p/10128356.html

Shanghai Barcamp

早上起来晚了&#xff0c;晚睡晚起的习惯很不好&#xff01;总是有段时间会养成这样的不好习惯&#xff0c;过一段时间又会早睡早起。总结的说&#xff0c;去了还是有不少收获的&#xff0c;而且刚好就在前一段时间看了不少关于vc和初期投资培养方面的知识&#xff0c;结果这次…

我的虚拟机上网记录

联网时把虚拟机设置成共享IP模式就可以。如果要通过NFS链接开发板就选择桥接网络

随堂小测冲刺.第19天

我们小组的logo出来的&#xff0c;太酷了&#xff0c;不符合我的审美&#xff0c;本人表示无法接受。。。 还要谢谢李泽宇的女盆友&#xff0c;O(∩_∩)O哈哈~ 转载于:https://www.cnblogs.com/daisy99lijing/p/11024465.html

对象存储系统Swift官方文档

对象存储系统Swift技术详解&#xff1a;综述与概念 OpenStack Object Storage (Swift) 是用来创建冗余的、可扩展的对象存储&#xff08;引擎&#xff09;的开源软件。通过阅读Swift的技术文档&#xff0c;我们可以理解其中的设计的原理和实现的方法 。 Swift项目已经进展有两年…

MSBuild编译扩展

新增一个C#工程&#xff0c;用记事本打开工程文件&#xff08;.csproj结尾&#xff09;&#xff0c;滚动条拉到最后&#xff0c;大家可以看到一段如下的代码&#xff0c;其中<Target Name"BeforeBuild">和<Target Name"AfterBuild">大家根据名…

电影bt

电影&#xff1a; http://www.bttiantang.com/

修改2440里面的FriendlyARM

修改2440里面的FriendlyARM 在/etc/init.d文件夹里面有一个rcS文件&#xff0c;修改/bin/hostname FriendlyARM中的FriendlyARM即可 比如修改为/bin/hostname Solar posted on 2011-12-07 17:22 Neddy11 阅读(...) 评论(...) 编辑 收藏 转载于:https://www.cnblogs.com/Neddy…