typescript TSLint 摆脱缺失的空白
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35489086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TSLint get rid of missing-whitespace
提问by ThinkBonobo
I've been trying to scour the internet to solve this but to no avail. Perhaps you can help me. I am getting tslint 'missing whitespace' warnings that say something like:
我一直试图在互联网上搜索以解决此问题,但无济于事。或许你能帮帮我。我收到 tslint 'missing whitespace' 警告,内容如下:
WARNING in ./src/app/content/content.controller.ts [4, 13]: missing whitespace [5, 21]: missing whitespace
./src/app/content/content.controller.ts [4, 13] 中的警告:缺少空格 [5, 21]:缺少空格
I want to get rid of the warning
我想摆脱警告
Here's an example of the code.... basically anywhere I have a colon for declaring type is where the error is happening. I don't want to put a space between it so I'd like the linter to not bug me about it...
这是代码的一个例子......基本上我有一个用于声明类型的冒号的任何地方都是发生错误的地方。我不想在它之间留一个空格,所以我希望短绒不会打扰我......
export class ContentCtrl {
filters:IFilter[];
selectedFilters:IFilter[];
filterToAdd:IFilter;
/** @ngInject */
constructor(private $log:angular.ILogService,
private $timeout:any,
private toastr:any,
private filterService:FilterService) {
const self = this;
I looked through the tslint.json file and could not figure out how to get rid of it.
我查看了 tslint.json 文件,但不知道如何摆脱它。
I saw a promising property that said: "typedef-whitespace"
我看到了一个很有前途的属性,上面写着:“typedef-whitespace”
I changed it to the following but, alas, to no-avail:
我将其更改为以下内容,但可惜没有用:
"typedef-whitespace": [true,
{
"callSignature": "noSpace",
"catchClause": "noSpace",
"indexSignature": "noSpace",
"parameter": "noSpace"
}
],
How do I get rid of the 'missing whitespace' error?
如何摆脱“缺少空格”错误?
回答by JKillian
This error message comes from the whitespace rule. I believe the rule wants you to add a space either before or after (not sure which) the colon in type declarations. However, if you don't like this, you can disable the rule completely, or remove the check-type
option from your tslint.json
file.
此错误消息来自空白规则。我相信该规则希望您在类型声明中的冒号之前或之后(不确定是哪个)添加一个空格。但是,如果您不喜欢这样,您可以完全禁用该规则,或check-type
从您的tslint.json
文件中删除该选项。
回答by Yue Ming
You should search whitespace
in tslint.json
,and replace all result whith false
.
你应该寻找whitespace
在tslint.json
,并更换所有结果蒙山false
。
And you questions can set like there:
你的问题可以像那里一样设置:
"whitespace": [
false,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
set it ,if you write private nima:string, : with no space will no err.
设置它,如果你写private nima:string, : 没有空格不会出错。
other,
其他,
if you set one-line
's metadata to false
,the class can follow no space.
如果您将one-line
的元数据设置为false
,则该类可以没有空格。
if yout set no-trailing-whitespace
to false
, the line can use tab.
如果设置no-trailing-whitespace
为false
,则该行可以使用制表符。
——end
- 结尾