Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rewrite tslint rule for particular file?

I prefer quotemark: [true, "single"], but for lib.core.es6.d.ts I need use "double".

I tried use comments like eslint:

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

but it doesn't work.

Maybe I can ignore some files using tslint.json?

like image 612
Michael Avatar asked Feb 07 '16 11:02

Michael


People also ask

How do I create a Tslint file?

-i, --init: Generates a tslint. json config file in the current working directory. -o, --out: A filename to output the results to. By default, tslint outputs to stdout, which is usually the console where you're running it from.

How do I disable Tslint to a file?

In addition to global configuration, you may also enable/disable linting for a subset of lint rules within a file with the following comment rule flags: /* tslint:disable */ - Disable all rules for the rest of the file. /* tslint:enable */ - Enable all rules for the rest of the file.

What is the use of Tslint json file?

When using the CLI or many third-party tools, a file named tslint. json or tslint. yaml is used to configure which rules get run and each of their options.


2 Answers

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. 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.

like image 100
JKillian Avatar answered Nov 15 '22 10:11

JKillian


Hm... Comment like this work:

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

issue solved.

like image 32
Michael Avatar answered Nov 15 '22 10:11

Michael