Skip to content

Commit 7610790

Browse files
himynameisdaveljharb
authored andcommittedAug 16, 2021
[Docs] max-dependencies: 📖 Document ignoreTypeImports option
See #1847.
1 parent 8be2ec2 commit 7610790

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed
 

‎CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
99
### Fixed
1010
- `ExportMap`: Add default export when esModuleInterop is true and anything is exported ([#2184], thanks [@Maxim-Mazurok])
1111

12+
### Changed
13+
- [Docs] `max-dependencies`: 📖 Document `ignoreTypeImports` option ([#2196], thanks [@himynameisdave])
14+
1215
## [2.24.0] - 2021-08-08
1316

1417
### Added
@@ -887,6 +890,7 @@ for info on changes for earlier releases.
887890

888891
[`memo-parser`]: ./memo-parser/README.md
889892

893+
[#2196]: https://github.com/import-js/eslint-plugin-import/pull/2196
890894
[#2184]: https://github.com/import-js/eslint-plugin-import/pull/2184
891895
[#2179]: https://github.com/import-js/eslint-plugin-import/pull/2179
892896
[#2160]: https://github.com/import-js/eslint-plugin-import/pull/2160
@@ -1401,6 +1405,7 @@ for info on changes for earlier releases.
14011405
[@grit96]: https://github.com/grit96
14021406
[@guillaumewuip]: https://github.com/guillaumewuip
14031407
[@hayes]: https://github.com/hayes
1408+
[@himynameisdave]: https://github.com/himynameisdave
14041409
[@hulkish]: https://github.com/hulkish
14051410
[@Hypnosphi]: https://github.com/Hypnosphi
14061411
[@isiahmeadows]: https://github.com/isiahmeadows

‎docs/rules/max-dependencies.md

+30-8
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ This is a useful rule because a module with too many dependencies is a code smel
66

77
Importing multiple named exports from a single module will only count once (e.g. `import {x, y, z} from './foo'` will only count as a single dependency).
88

9-
### Options
9+
## Options
1010

11-
This rule takes the following option:
12-
13-
`max`: The maximum number of dependencies allowed. Anything over will trigger the rule. **Default is 10** if the rule is enabled and no `max` is specified.
14-
15-
You can set the option like this:
11+
This rule has the following options, with these defaults:
1612

1713
```js
18-
"import/max-dependencies": ["error", {"max": 10}]
14+
"import/max-dependencies": ["error", {
15+
"max": 10,
16+
"ignoreTypeImports": false,
17+
}]
1918
```
2019

20+
### `max`
2121

22-
## Example
22+
This option sets the maximum number of dependencies allowed. Anything over will trigger the rule. **Default is 10** if the rule is enabled and no `max` is specified.
2323

2424
Given a max value of `{"max": 2}`:
2525

@@ -39,6 +39,28 @@ const anotherA = require('./a'); // still 1
3939
import {x, y, z} from './foo'; // 2
4040
```
4141

42+
### `ignoreTypeImports`
43+
44+
Ignores `type` imports. Type imports are a feature released in TypeScript 3.8, you can [read more here](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export). Defaults to `false`.
45+
46+
Given `{"max": 2, "ignoreTypeImports": true}`:
47+
48+
### Fail
49+
50+
```ts
51+
import a from './a';
52+
import b from './b';
53+
import c from './c';
54+
```
55+
56+
### Pass
57+
58+
```ts
59+
import a from './a';
60+
import b from './b';
61+
import type c from './c'; // Doesn't count against max
62+
```
63+
4264
## When Not To Use It
4365

4466
If you don't care how many dependencies a module has.

0 commit comments

Comments
 (0)
Please sign in to comment.