Skip to content

Commit

Permalink
extra detail about no-duplicates. closes #242
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Jul 2, 2016
1 parent 7a03512 commit 82de4db
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/rules/no-duplicates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

Reports if a resolved path is imported more than once.

ESLint core has a similar rule ([`no-duplicate-imports`](http://eslint.org/docs/rules/no-duplicate-imports)), but this version
is different in two key ways:

1. the paths in the source code don't have to exactly match, they just have to point to the same module on the filesystem. (i.e. `./foo` and `./foo.js`)
2. this version distinguishes Flow `type` imports from standard imports. ([#334](https://github.com/benmosher/eslint-plugin-import/pull/334))

## Rule Details

Valid:
```js
import SomeDefaultClass, * as names from './mod'
// Flow `type` import from same module is fine
import type SomeType from './mod'
```

...whereas here, both `./mod` imports will be reported:
Expand All @@ -18,6 +26,9 @@ import SomeDefaultClass from './mod'
import foo from './some-other-mod'

import * as names from './mod'

// will catch this too, assuming it is the same target module
import { something } from './mod.js'
```

The motivation is that this is likely a result of two developers importing different
Expand All @@ -26,5 +37,7 @@ locations in the file.) This rule brings both (or n-many) to attention.

## When Not To Use It

If the core ESLint version is good enough (i.e. you're _not_ using Flow and you _are_ using [`import/extensions`](./extensions.md)), keep it and don't use this.

If you like to split up imports across lines or may need to import a default and a namespace,
you may want to disable this rule.
you may not want to enable this rule.

0 comments on commit 82de4db

Please sign in to comment.