import-js/eslint-plugin-import

no-duplicates should remove duplicate elements

Open

#1812 aperta il 8 giu 2020

Vedi su GitHub
 (4 commenti) (2 reazioni) (0 assegnatari)JavaScript (1540 fork)batch import
bughelp wanted

Metriche repository

Star
 (4946 star)
Metriche merge PR
 (Merge medio 138g 22h) (3 PR mergiate in 30 g)

Descrizione

no-duplicates should remove duplicate Imported values.

This case is most commonly seen when resolving merge conflicts where identical imports can be copied. It would be helpful if the fix were able to de-duplicate the imported values themselves not only the paths.

// bad
import { foo } from '../foo'
import { bar } from '../bar'
import { foo } from '../foo'

// current fix
import { foo, foo } from '../foo' // <-- creates duplicate imported values
import { bar } from '../bar'

// idealized fix
import { foo } from '../foo' // <-- removed duplicated value
import { bar } from '../bar'

Edge cases

// used with `as` with same naming
import { foo as newFoo } from '../foo'
import { bar } from '../bar'
import { foo as newFoo } from '../foo'

// current fix
import { foo as newFoo, foo as newFoo } from '../foo' // <-- removed duplicated value
import { bar } from '../bar'

// idealized fix
import { foo as newFoo } from '../foo' // <-- removed duplicated value
import { bar } from '../bar'
// used with `as` with different naming
import { foo as foo1 } from '../foo'
import { bar } from '../bar'
import { foo as foo2 } from '../foo'

// current and idealized fix to avoid naming collisions 
import { foo as foo1, foo as foo2 } from '../foo' // <-- removed duplicated value
import { bar } from '../bar'

Guida contributor