import-js/eslint-plugin-import
在 GitHub 查看no-duplicates should remove duplicate elements
Open
#1,812 创建于 2020年6月8日
bughelp wanted
描述
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'