Skip to content

Commit

Permalink
[Docs] max-dependencies: 📖 Document ignoreTypeImports option
Browse files Browse the repository at this point in the history
See #1847.
  • Loading branch information
himynameisdave authored and ljharb committed Aug 16, 2021
1 parent 8be2ec2 commit 7610790
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
### Fixed
- `ExportMap`: Add default export when esModuleInterop is true and anything is exported ([#2184], thanks [@Maxim-Mazurok])

### Changed
- [Docs] `max-dependencies`: 📖 Document `ignoreTypeImports` option ([#2196], thanks [@himynameisdave])

## [2.24.0] - 2021-08-08

### Added
Expand Down Expand Up @@ -887,6 +890,7 @@ for info on changes for earlier releases.

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

[#2196]: https://github.com/import-js/eslint-plugin-import/pull/2196
[#2184]: https://github.com/import-js/eslint-plugin-import/pull/2184
[#2179]: https://github.com/import-js/eslint-plugin-import/pull/2179
[#2160]: https://github.com/import-js/eslint-plugin-import/pull/2160
Expand Down Expand Up @@ -1401,6 +1405,7 @@ for info on changes for earlier releases.
[@grit96]: https://github.com/grit96
[@guillaumewuip]: https://github.com/guillaumewuip
[@hayes]: https://github.com/hayes
[@himynameisdave]: https://github.com/himynameisdave
[@hulkish]: https://github.com/hulkish
[@Hypnosphi]: https://github.com/Hypnosphi
[@isiahmeadows]: https://github.com/isiahmeadows
Expand Down
38 changes: 30 additions & 8 deletions docs/rules/max-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ This is a useful rule because a module with too many dependencies is a code smel

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

### Options
## Options

This rule takes the following option:

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

You can set the option like this:
This rule has the following options, with these defaults:

```js
"import/max-dependencies": ["error", {"max": 10}]
"import/max-dependencies": ["error", {
"max": 10,
"ignoreTypeImports": false,
}]
```

### `max`

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

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

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

### `ignoreTypeImports`

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

Given `{"max": 2, "ignoreTypeImports": true}`:

### Fail

```ts
import a from './a';
import b from './b';
import c from './c';
```

### Pass

```ts
import a from './a';
import b from './b';
import type c from './c'; // Doesn't count against max
```

## When Not To Use It

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

0 comments on commit 7610790

Please sign in to comment.