Skip to content

[no-restricted-imports] extend to support type-only imports #2661

@yoyo930021

Description

@yoyo930021
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

We need to limit only type import some packages sometimes.
For example:
When using package in user project runtimes, Like vetur, ts-loader.

Rule Details

This rule limit only type import some package within your codebase.

Options

type Options = {
  packages: Array<{ name: string, reason: string }>
};

Example

Incorrect code for { packages: [{ name: 'typescript', reason: 'runtime dependency' }] }

import ts from 'typescript'
import * as ts from 'typescript'
import { findPackageConfig } from 'typescript'

correct code for { packages: [{ name: 'typescript', reason: 'runtime dependency' }] }

import type ts from 'typescript'
import type * as ts from 'typescript'
import type { findPackageConfig } from 'typescript'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy