TSLint 摆脱缺失的空白 [英] TSLint get rid of missing-whitespace

查看:50
本文介绍了TSLint 摆脱缺失的空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在互联网上搜索以解决此问题,但无济于事.或许你能帮帮我.我收到 tslint 'missing whitespace' 警告,内容如下:

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:

./src/app/content/content.controller.ts 中的警告[4, 13]:缺少空格[5, 21]:缺少空格

WARNING in ./src/app/content/content.controller.ts [4, 13]: missing whitespace [5, 21]: missing whitespace

我想去掉警告

这是代码的一个例子....基本上任何我有一个用于声明类型的冒号的地方都是发生错误的地方.我不想在它之间留一个空格,所以我希望短绒不会打扰我......

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;

我查看了 tslint.json 文件,但不知道如何摆脱它.

I looked through the tslint.json file and could not figure out how to get rid of it.

我看到了一个很有前途的属性,上面写着:typedef-whitespace"

I saw a promising property that said: "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?

推荐答案

此错误信息来自 空白规则.我相信该规则希望您在类型声明中的冒号之前或之后(不确定是哪个)添加一个空格.但是,如果您不喜欢这样,您可以完全禁用该规则,或者从您的 tslint.json 文件中删除 check-type 选项.

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.

这篇关于TSLint 摆脱缺失的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆