简体   繁体   English

如何为特定文件重写tslint规则?

[英]How to rewrite tslint rule for particular file?

I prefer quotemark: [true, "single"], but for lib.core.es6.d.ts I need use "double". 我更喜欢quotemark:[true,“single”],但对于lib.core.es6.d.ts,我需要使用“double”。

I tried use comments like eslint: 我尝试过像eslint这样的评论:

/*tslint qoutemark: [true, "double"]*/

but it doesn't work. 但它不起作用。

Maybe I can ignore some files using tslint.json? 也许我可以使用tslint.json忽略一些文件?

Currently you cannot change the options for a rule - you can only enable/disable a rule for specific lines of code. 目前,您无法更改规则的选项 - 您只能为特定代码行启用/禁用规则。

For example, say you had the object-literal-sort-keys rule enabled in your tslint.json file. 例如,假设您在tslint.json文件中启用了object-literal-sort-keys规则。 You could then do something like this to disable it for a portion of a file and then renable it for the rest of the file: 然后,您可以执行类似的操作,为文件的一部分禁用它,然后将其重命名为文件的其余部分:

/* tslint:disable:object-literal-sort-keys */
const range = {
   min: 5,
   middle: 10,    // TSLint will *not* warn about unsorted keys here
   max: 20
};
/* tslint:enable:object-literal-sort-keys */

See the TSLint website for more information. 有关更多信息,请参见TSLint网站

Hm... Comment like this work: 嗯......评论喜欢这个作品:

/* tslint:disable:variable-name quotemark:[true, "double"] */

issue solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM