eslint-plugin-import
eslint-plugin-import copied to clipboard
Request: option to let `no-duplicates` force type & normal imports to be de-duplicated
#225 asked to allow both type & normal imports to be allowed together, e.g.
import {someFunction} from '../src/foo';
import type {someType} from '../src/foo';
This was requested because according to the author there was no way to merge these together at that point in time.
However, currently flow does support merging these imports together:
import { someFunction, type someType } from '../src/foo';
I think it would therefore be useful if no-duplicates
could be configured to have the same behaviour as before #225, i.e. to require type & normal imports to be merged.
this should be optional
I agree this should be controlled by an option.
Some progress?
@loyd not til somebody submits a PR ¯\_(ツ)_/¯
Regular imports and type imports can be merged in TypeScript as well by the same logic. The difference with flow is that in TypeScript, the type imports will look like regular imports.
import {someFunction} from '../src/foo';
import type {someType} from '../src/foo';
becomes
import {someFunction, someType} from '../src/foo';
TypeScript 4.5 also supports inline type
: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names
We'd probably have to detect TS version regardless to support that, and we may want it to be a separate option. Let's explore it in #2229.
any progress in this?
I'd assume somebody picking up #2229 would be welcome, so I suggest starting there 🙂