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
Copy file name to clipboardExpand all lines: README.md
+37-65Lines changed: 37 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,41 @@ module.exports = {
24
24
};
25
25
```
26
26
27
+
### TypeScript
28
+
29
+
TypeScript support is currently experimental, and available separately. Make sure to install `typescript` v3 or v4 on your project, then:
30
+
31
+
```js
32
+
module.exports= {
33
+
// See https://github.com/torchbox/eslint-config-torchbox for rules.
34
+
extends:'torchbox/typescript',
35
+
};
36
+
```
37
+
38
+
The TypeScript configuration uses the same rules as the base configuration, with two exceptions:
39
+
40
+
- Rules which will be checked by the TypeScript compiler anyway are disabled.
41
+
- Rules which would work differently for TypeScript code have been replaced by their [@typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin), where this is possible without requiring type checking as part of linting (see [Design decisions](#design-decisions)).
42
+
43
+
#### Advanced TypeScript usage
44
+
45
+
For projects wanting stricter checks, consider using [linting with type information](https://typescript-eslint.io/docs/linting/type-linting/) Here is a sample ESLint configuration:
46
+
47
+
```js
48
+
module.exports= {
49
+
// See https://github.com/torchbox/eslint-config-torchbox for rules.
// See https://typescript-eslint.io/docs/linting/type-linting/.
55
+
parserOptions: {
56
+
tsconfigRootDir:__dirname,
57
+
project: ['./tsconfig.json'],
58
+
},
59
+
};
60
+
```
61
+
27
62
### Tips
28
63
29
64
#### Common CLI flags
@@ -72,70 +107,6 @@ module.exports = {
72
107
};
73
108
```
74
109
75
-
### TypeScript
76
-
77
-
This config doesn’t include TypeScript support out of the box. We can install and configure a TypeScript parser and ESLint plugin to make it compatible. Here is how to proceed:
Note that the TypeScript-friendly rules included in the config above aren’t as strict as our baseline config. To bridge this gap, consider using `--max-warnings 0` to treat all warnings as errors:
This config is meant first and foremost for React projects, where it will detect which rules to apply based on the version of React used on the project. The config can also be used on non-React projects – just make sure to disable the version check by adding: the following in your config:
- Additionally for TypeScript, [`plugin:@typescript-eslint/recommended`](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin#supported-rules)
0 commit comments