Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto import exclude specific member from module #215

Open
tjx666 opened this issue Jul 1, 2024 · 1 comment
Open

auto import exclude specific member from module #215

tjx666 opened this issue Jul 1, 2024 · 1 comment
Assignees

Comments

@tjx666
Copy link

tjx666 commented Jul 1, 2024

I use next-nprogress-bar in my next.js project, but ts will sometimes import useRouter from next-nprogress-bar which is not my expected:

import { useRouter } from 'next-nprogress-bar';

export function useRenderPageAsComp(pagePathname: string) {
  const { pathname } = useRouter();
  return pathname !== pagePathname;
}

Solution

depracetd old seeting suggestions.ignoreAutoImports" and extend it to `suggestions.autoImports":

"suggestions.autoImports": [
  {
    "modules": ["path"], // ignore path, but not path/posix or path/win32 modules,
    "members": []
  }
  {
    "modules": ["next-nprogress-bar"],
    "excludeMembers": ["useRouter"] // will exclude useRouter from next-nprogress-bar
  },
  {
    "modules": ["@mui/material"],
    "excludeMembers": ["SxProps"] // will exclude type SxProps from @mui/material
  },
  {
    "modules": ["@mui/system"],
    "members": ["SystemCssProperties"], will exclude all other members except for `SystemCssProperties`
  }
]

Maybe you can get some inspiration from https://eslint.org/docs/latest/rules/no-restricted-imports

@zardoy
Copy link
Owner

zardoy commented Jul 2, 2024

Most of things are available now, but that's a great idea to rework the setting to make it easier to configure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants