Bukoye
Bukoye

Reputation: 71

is there any way to automatically import modules in eslint or vscode?

so I created a consoledata.ts file to log whatever I pass in it as an argument like so:

/* eslint-disable no-console */
export default function ConsoleData(props: any) {
  console.log(props);
}

now using the VSCode search icon, I changed every console.log in my code to consoleData since it'll probably take me all day to change them one by one. now my issue is, the consoleData module is not imported. is there a way I can do this?

Upvotes: 2

Views: 4081

Answers (2)

SoHeil Vatanpoor
SoHeil Vatanpoor

Reputation: 11

You can use this plugin to identify unresolved imports, which can be fixed by IDE's fix options or --fix flag for eslint. If you use aliases, check this one as well.

Upvotes: 0

yum
yum

Reputation: 1263

There are two ways to auto import in VSCode. The first way is using quick fix. If you are on MacOS, you can do Cmd + . to open the quick fix dialog and then you import the module.

The second option is to use auto import suggestions. They show suggestions as you type. If you are on MacOS, select the function/class you want to import and then you can do Ctrl + Space to open the auto import suggestions dialog.

Upvotes: 1

Related Questions