Skip to content

Commit 2efa66f

Browse files
committed
Change readme
1 parent e95fc6b commit 2efa66f

File tree

2 files changed

+60
-21
lines changed

2 files changed

+60
-21
lines changed

README.md

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,53 @@
22

33
This resolver adds [`TypeScript`][] or [`JavaScript`][] import support to [`eslint-plugin-import`][] with `tsconfig.json` or `jsconfig.json` aliases (`compilerOptions.paths`)
44

5-
This is fork of [`eslint-import-resolver-typescript`][] but much faster **(~30-40%)**
5+
### Performance
66

7-
For example we can use `strace` package for count of [fstat](`https://nodejs.org/api/fs.html#fsfstatsyncfd-options`) call when linting you codebase
7+
This is fork of [`eslint-import-resolver-typescript`][] but much faster and more efficient. You can save time on project linting by **(~30-40%)**.
88

9-
Example you codebase has multiple packages with 100k LOC and more
9+
![eslint-import-resolver-x vs eslint-import-resolver-typescript](image.png)
10+
11+
We use `strace` package for count of [fstat](`https://nodejs.org/api/fs.html#fsfstatsyncfd-options`) call when linting codebase
12+
13+
For example you codebase has multiple packages with 100 000 LOC ()
14+
15+
```
16+
The following data depends directly on the number of imports in your case, but the comparison table is filled with data on the same code base
17+
```
18+
19+
50641
20+
1
21+
78
22+
1
23+
3
24+
2
25+
32137
26+
81592
27+
1194240
28+
2
29+
11734655
30+
2
1031

1132
| syscall | eslint-import-resolver-x | eslint-import-resolver-typescript |
1233
| ---------- | ------------------------ | --------------------------------- |
13-
| access | 85 027 |
14-
| chdir | 1 |
15-
| execve | 78 |
16-
| faccessat2 | 1 |
17-
| getcwd | 3 |
18-
| mkdir | 2 |
19-
| newfstatat | 31 761 |
20-
| openat | 86 287 |
21-
| readlink | 1 183 633 |
22-
| statfs | 2 |
23-
| statx | 1 081 306 |
24-
| unlink | 3 |
25-
26-
We are interested in how many accesses to the file system occurred during the linting process. We can pay attention to `statx` syscall.
27-
28-
`eslint-import-resolver-x` makes calls `statx` 10x+ times less.
34+
| access | 52 900 | 50 641 |
35+
| chdir | 1 | 1 |
36+
| execve | 78 | 78 |
37+
| faccessat2 | 1 | 1 |
38+
| getcwd | 3 | 3 |
39+
| mkdir | 2 | 2 |
40+
| newfstatat | 31 761 | 32 137 🔺 |
41+
| openat | 74 965 | 81 592 🔺 |
42+
| readlink | 1 183 525 | 1 194 240 🔺 |
43+
| statfs | 2 | 2 |
44+
| statx | 1 058 381 | 11 734 655 🔺 |
45+
| unlink | 3 | 2 |
46+
47+
We are interested in how many accesses to the file system occurred during the linting process.
48+
49+
For example we can pay attention to `statx` syscall.
50+
51+
`eslint-import-resolver-x` makes **10 MILLION fewer** `statx` calls
2952

3053
**If you notice an increase in linting performance in your CI on large code bases, write your feedback [here](https://github.com/helljs/eslint-import-resolver-x/discussions/1)**
3154

@@ -69,7 +92,7 @@ Add the following to your `.eslintrc` config:
6992
"@typescript-eslint/parser": [".ts", ".tsx"],
7093
},
7194
"import/resolver": {
72-
"x": {
95+
"@helljs/eslint-import-resolver-x": {
7396
"alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
7497

7598
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default
@@ -107,7 +130,7 @@ Add the following to your `.eslintrc` config:
107130
"@babel/eslint-parser": [".js", ".mjs"],
108131
},
109132
"import/resolver": {
110-
"x": {
133+
"@helljs/eslint-import-resolver-x": {
111134
// use <root>/path/to/folder/jsconfig.json
112135
"project": "path/to/folder",
113136

@@ -127,6 +150,22 @@ Add the following to your `.eslintrc` config:
127150
}
128151
```
129152

153+
You can use this resolver for mixed codebase with javascript & typescript:
154+
155+
```jsonc
156+
"settings": {
157+
"import/parsers": {
158+
"@babel/eslint-parser": [".js", ".mjs"],
159+
"@typescript-eslint/parser": [".ts", ".tsx"],
160+
},
161+
"import/resolver": {
162+
"@helljs/eslint-import-resolver-x": {
163+
"project": ["packages/*/tsconfig.json", "packages/*/jsconfig.json"],
164+
},
165+
},
166+
}
167+
```
168+
130169
## Options from [`enhanced-resolve`][]
131170

132171
#### `conditionNames` - [See default](src/default.ts#1)

image.png

60.7 KB
Loading

0 commit comments

Comments
 (0)