You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- automatic fixing of formatting & style violations
17
18
- integration with [msbuild](https://github.com/joshuakgoldberg/tslint.msbuild), [grunt](https://github.com/palantir/grunt-tslint), [gulp](https://github.com/panuhorsmalahti/gulp-tslint), [atom](https://github.com/AtomLinter/linter-tslint), [eclipse](https://github.com/palantir/eclipse-tslint), [emacs](http://flycheck.org), [sublime](https://packagecontrol.io/packages/SublimeLinter-contrib-tslint), [vim](https://github.com/scrooloose/syntastic), [visual studio](https://visualstudiogallery.msdn.microsoft.com/6edc26d4-47d8-4987-82ee-7c820d79be1d), [vscode](https://marketplace.visualstudio.com/items?itemName=eg2.tslint), [webstorm](https://www.jetbrains.com/webstorm/help/tslint.html), and more
18
19
19
20
Table of Contents
@@ -115,7 +116,7 @@ Options:
115
116
```
116
117
-c, --config configuration file
117
118
-e, --exclude exclude globs from path expansion
118
-
--fix Fixes linting errors for select rules. This may overwrite linted files
119
+
--fix fixes linting errors for select rules (this may overwrite linted files)
119
120
--force return status code 0 even if there are lint errors
120
121
-h, --help display detailed help
121
122
-i, --init generate a tslint.json config file in the current working directory
@@ -213,9 +214,9 @@ tslint accepts the following command-line options:
213
214
214
215
#### Library
215
216
216
-
```javascript
217
-
constLinter=require("tslint");
218
-
constfs=require("fs");
217
+
```js
218
+
import { Linter} from"tslint";
219
+
import*asfsfrom"fs";
219
220
220
221
constfileName="Specify file name";
221
222
constconfiguration= {
@@ -240,7 +241,7 @@ const result = linter.lint();
240
241
241
242
To enable rules that work with the type checker, a TypeScript program object must be passed to the linter when using the programmatic API. Helper functions are provided to create a program from a `tsconfig.json` file. A project directory can be specified if project files do not lie in the same directory as the `tsconfig.json` file.
Then, if using the CLI, provide the directory that contains this rule as an option to `--rules-dir`. If using TSLint as a library or via `grunt-tslint`, the `options` hash must contain `"rulesDirectory": "..."`. If you run the linter, you'll see that we have now successfully banned all import statements via TSLint!
357
358
358
-
Finally, enable each custom rule in your [`tslint.json` config file][0] config file.
359
+
Finally, enable each custom rule in your [`tslint.json` config file](https://palantir.github.io/tslint/usage/tslint-json/) config file.
359
360
360
361
Final notes:
361
362
@@ -370,11 +371,11 @@ Just like rules, additional formatters can also be supplied to TSLint via `--for
Copy file name to clipboardexpand all lines: docs/_data/rules.json
+2-2
Original file line number
Diff line number
Diff line change
@@ -296,7 +296,7 @@
296
296
},
297
297
{
298
298
"ruleName": "max-classes-per-file",
299
-
"description": "\nA file may not contain more than the specified number of classes\nif the file name does not match the \"ignore-filename-pattern\" option",
299
+
"description": "\nA file may not contain more than the specified number of classes",
300
300
"rationale": "\nEnsures that files have a single responsibility so that that classes each exist in their own files",
301
301
"optionsDescription": "\nThe one required argument is an integer indicating the maximum number of classes that can appear in a file.",
302
302
"options": {
@@ -850,7 +850,7 @@
850
850
},
851
851
{
852
852
"ruleName": "no-unused-variable",
853
-
"deprecationMessage": "Use the compiler options --noUnusedParameters and --noUnusedLocals instead.",
853
+
"deprecationMessage": "Use the tsc compiler options --noUnusedParameters and --noUnusedLocals instead.",
854
854
"description": "Disallows unused imports, variables, functions and private class members.",
855
855
"optionsDescription": "\nThree optional arguments may be optionally provided:\n\n* `\"check-parameters\"` disallows unused function and constructor parameters.\n * NOTE: this option is experimental and does not work with classes\n that use abstract method declarations, among other things.\n* `\"react\"` relaxes the rule for a namespace import named `React`\n(from either the module `\"react\"` or `\"react/addons\"`).\nAny JSX expression in the file will be treated as a usage of `React`\n(because it expands to `React.createElement `).\n* `{\"ignore-pattern\": \"pattern\"}` where pattern is a case-sensitive regexp.\nVariable names that match the pattern will be ignored.",
Copy file name to clipboardexpand all lines: docs/_posts/2016-11-17-new-for-4.0.md
+5-2
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,15 @@ TSLint 4.0 has been released! With this release comes a few exciting [changes][0
15
15
*[semicolon][7]
16
16
*[trailing-comma][8]
17
17
18
-
***Linting `.js` files**. *A much-requested feature from our community*. Simplify your toolset by running the same rules you know and love on your .js and .jsx files. Just add a `jsRules`[section][9] to your `tslint.json` file, and TSLint will your JavaScript files.
19
18
20
-
***TypeScript 2.0+ required**. This lets us deprecate/remove rules that are checked by the compiler. These rules now cause compilation errors:
19
+
***Linting `.js` files**. *A much-requested feature from our community*. Simplify your toolset by running the same rules you know and love on your .js and .jsx files. Just add a `jsRules`[section][9] to your `tslint.json` file, and TSLint will lint your JavaScript files.
20
+
21
+
***TypeScript 2.0+ required**. This lets us deprecate/remove rules that are checked by the compiler. Problematic code that once violated these rules now cause compilation errors in `tsc`:
21
22
* no-duplicate-key
22
23
* no-unreachable
23
24
* no-unused-variable
24
25
26
+
25
27
***Node.js API Change**. [Moved and renamed][11] some things to make more sense. Get it all when you use `import * as TSLint from "tslint"`.
26
28
27
29
***[Recommended Rules Updated][12]**
@@ -36,6 +38,7 @@ TSLint 4.0 has been released! With this release comes a few exciting [changes][0
Copy file name to clipboardexpand all lines: docs/develop/custom-rules/index.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,10 @@ TSLint ships with a set of core rules that can be configured. However, users are
8
8
Let us take the example of how to write a new rule to forbid all import statements (you know, *for science*). Let us name the rule file `noImportsRule.ts`. Rules are referenced in `tslint.json` with their kebab-cased identifer, so `"no-imports": true` would configure the rule.
9
9
10
10
__Important conventions__:
11
-
* Rule identifiers are always kebab-cased.
12
-
* Rule files are always camel-cased (`camelCasedRule.ts`).
13
-
* Rule files *must* contain the suffix `Rule`.
14
-
* The exported class must always be named `Rule` and extend from `Lint.Rules.AbstractRule`.
11
+
- Rule identifiers are always kebab-cased.
12
+
- Rule files are always camel-cased (`camelCasedRule.ts`).
13
+
- Rule files *must* contain the suffix `Rule`.
14
+
- The exported class must always be named `Rule` and extend from `Lint.Rules.AbstractRule`.
15
15
16
16
Now, let us first write the rule in TypeScript:
17
17
@@ -58,12 +58,12 @@ Now that you're written a rule to detect problems, let's modify it to *fix* them
58
58
Instantiate a `Fix` object and pass it in as an argument to `addFailure`. This snippet replaces the offending import statement with an empty string:
0 commit comments