-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
I'd like to propose a third option for the consistent-type-imports rule's prefer
property. It currently has two options for prefer
: type-imports
and no-type-imports
. However, it would be very useful to have a third option:
- type-imports-combine: enforce all type-only imports to be
import type
except when there's already a concrete import from that same file, in which case prefer to combine the imports into a single statement.
Here's an example:
Logger.ts
export class Logger implements ILogger {
log(message: string) {
console.log(message);
}
}
export interface ILogger {
log(message: string);
}
main.ts
prefer: 'type-imports'
import { Logger } from './Logger';
import type { ILogger} from './Logger';
import type { SomeInterface } from './SomeInterface';
prefer: 'no-type-imports'
import { ILogger, Logger } from './Logger';
import { SomeInterface } from './SomeInterface';
New proposal:
prefer: 'type-imports-combine'
import { type ILogger, Logger } from './Logger';
import type { SomeInterface } from './SomeInterface';
elsassph, TwitchBronBron, adidahiya, exodustx0, RoystonS and 40 more
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin