TSLint:如何禁用所有样式/可读性规则 [英] TSLint: how to disable all style/readability rules

查看:61
本文介绍了TSLint:如何禁用所有样式/可读性规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL;DR: 有没有办法关闭所有与代码风格/可读性有关的 TSLint 规则?除此之外,有没有办法关闭所有与我的代码能否正确编译无关的 TSLint 规则?

TL;DR: Is there a way to turn off all TSLint rules that have to do with code style/readability? Barring that, is there a way to turn off all TSLint rules that don't pertain to whether my code will compile properly?

详情:我将 WebStorm IDE 用于 Angular 项目,它使用 TSLint.我喜欢 TSLint 的实时警告/错误,因为我对 JavaScript 还很陌生,即时反馈简化了我的学习过程.

Details: I'm using the WebStorm IDE for an Angular project, and it uses TSLint. I like TSLint's real-time warnings/errors, as I am fairly new to JavaScript and the instant feedback streamlines my learning process.

然而,我不喜欢 TSLint 如何给我关于样式/格式的警告.例如,如果我没有在两件事之间放置一个空格,或者如果我在一行上有一个花括号.我想要警告告诉我我的实际代码的问题,而不是某人对我的代码应该如何看待的意见.我尊重它们对某些人来说一定很有价值 - 我只是不是其中之一.

However, I don't like how TSLint gives me warnings about style/formatting. For example, if I don't put a space between two things or if I have a curly brace on a line by itself. I want warnings to tell me about problems with my actual code, rather than someone's opinions about how my code should look. I respect that they must be valuable to some people - I'm just not one of them.

在 TSLint 官方网站的规则页面,它列出了我要删除的规则在称为风格"的单一类别下.虽然我发现了各种关于如何关闭单个规则的帖子,比如whitespace",我一直无法找到有关如何禁用整个规则类别的任何信息......我希望它存在,因为有很多规则.

On the official TSLint site's rules page, it lists the rules I want to remove under a single category called "Style". While I've found various posts about how to turn off individual rules like "whitespace", I haven't been able to dig up anything about how to disable this entire category of rules...and I'm hoping it exists, because there are a lot of rules.

有没有办法在不单独禁用每个规则的情况下做到这一点?

Is there any way to do this without disabling every rule individually?

推荐答案

根据 TSLint 开发人员的说法,TSLint 默认没有激活的规则,因此不需要关闭它们.我错误地认为 TSLint 有默认规则,但实际上实际问题是其他人将 tslint.json 文件放在我没想到的目录中.将这个文件重新定位到更合适的位置解决了问题.

According to the TSLint developers, TSLint has no rules active by default, so there should be no need to turn them off. I mistakenly thought that TSLint had default rules, when in fact the actual problem was that someone else had put a tslint.json file in a directory I did not expect to find it in. Relocating this file to a more appropriate place fixed the problem.

这篇关于TSLint:如何禁用所有样式/可读性规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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