Giter Club home page Giter Club logo

vscode-extension-auto-import's Introduction

Auto Import - ES6, TS, JSX, TSX (VSCode Extension)

Automatically finds, parses and provides code actions and code completion for all available imports. Works with JavaScript (ES6) and TypeScript (TS). Forker from old repo vscode-extension-auto-import



Contributors


Configuration

filesToScan - Glob for which files in your workspace to scan, defaults to '**/*.{js, jsx, ts, tsx}'

showNotifications - Controls if the annoying notifications should be shown, defaults to false

doubleQuotes - Use double quotes rather than single

semicolon - Use a semicolon at the end of import statements, defaults to true

spaceBetweenBraces - Difference between import {test} and import { test }

autoComplete - Adds found items to intellisense and automatically imports then


Changelog

1.4.2

  • Fix issues #1 and #13

1.4.1

  • Add import action to quick fix menu
  • Added higher order component as a configuration option

1.4.0

  • fix jsx, tsx support
  • fix infinity loop search
  • fix export default keyword

1.3.3

  • considere flow type annotations

1.3.1 / 1.3.2

  • Update Metadata

1.3.0

1.2.2

  • Fix for imports not being merged.

1.2.1

  • Added optional auto completion for all known imports ( enabled by default ).
  • Improved scanning and seeking speed for large projects.
  • TSX Supported added, Thanks to lukeautry
  • Minor bug fixes and improvements.

1.0.2 / 1.0.3

1.0.1

  • Fixed breaking bug with vs 1.5.* and < TypeScript 2.0.0.

1.0

  • Few small tweaks and fixed error with vscode 1.5.*.

0.9

  • Added Import status bar, currently show you how many importable objects you have.
  • Correctly uses configured file paths for fileWatcher.
  • Fixed new exports not being immediately discovered.
  • CodeAction import paths are relative to the current file.
  • Typings are now excluded by default (along with node_modules and jspm_packages)

0.8.1

  • Fixed Windows paths issue

0.8

  • Nicer import paths.
  • Imports are now merged if they are from the same location.
  • Configuration for ' or ".
  • Works on Windows.
  • Now on Github.

0.7.0 / 0.7.1 / 0.7.2

  • Add configuration to control notifications and files to scan
  • Fixed a few bugs
  • Refactored code

0.6.0

  • Partial support for node_modules imports. AutoImport will scan your already used imports and provide them as suggestions when appropriate, so you will only need to type out your import once in one file and all other times will be handled by AutoImport. Version 0.7 will have full support for this.

0.5.1

  • General improvements, icon added and extension will now also watch for local file changes.

Todo

  • Work with node_modules (@angular / underscore for example).

Feel free to open an issue. Pull requests are also welcome

vscode-extension-auto-import's People

Contributors

andy-viv avatar fragsalat avatar garethflowers avatar lukeautry avatar maxjf1 avatar mohammed-io avatar nucllear avatar skorenuk avatar soates avatar third774 avatar vanackere avatar zhaoshengjun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-extension-auto-import's Issues

Combine exports from same modules with existing ones

So happy to find an auto-importer that actually works!

Imports should be combined with ones from existing modules.

Current Behavior, follow the numbered comments

import { Button, ListItem } from 'rmwc'; // (1) lets say I had these in a file already
import { Typography }  // (3) This line gets added

const Example = props => <Typography>Hi!</Typography> // (2) and then I auto-imported this

Expected Behavior

import { Button, ListItem, Typography } from 'rmwc'; // (2) and should end up on this line
const Example = props => <Typography>Hi!</Typography> // (1) This gets auto-imported

Does not add symbol to the existing import-list

  1. remove semicolon at the end of the existing import-list

  2. try to auto-import symbol with intellisense suggestion

  3. symbol is not being added to the import-list

  4. manually add semicolon to the end of import-list

  5. now auto-import correctly adds the symbol

Improve support for multiline import

This extension is really awesome! If it can also support for multiline import, it will be perfect.

Let's say original I've the following import statements at the top.

import React from 'react'
import {
  View,
  Text,
} from 'react-native';

When I put a new component in the render function (let's say <MyComponent />), the auto import will generate the new import in wrong place.

import React from 'react'
import {
import MyComponent from './MyComponent';
  View,
  Text,
} from 'react-native';

Expected:

import React from 'react'
import {
  View,
  Text,
} from 'react-native';
import MyComponent from './MyComponent';

higherOrderComponents seems not working

I added connectToStores in the config, and in one file i have one like export default connectToStores(ApplicationEdit);

the reason seems to be: the regex never matches when you have high order component.

it works for me when i changed
(export\\s?(default)?\\s?(class|interface|let|var|const|function)?) ((${this.higherOrderComponents}).+[, (])?(\\w+)
to
(export\\s?(default)?\\s?(class|interface|let|var|const|function)?) ((${this.higherOrderComponents}).*[, (])?(\\w+)
(.+ -> .*)

HttpClient import for Angular ~7.2.0

Thank you for your great plugin.
Could you, please, update it for Angular ~7.2.0.
For example HttpClient import for Angular is not suggested.

Typing import XXX amongst other imports, adds autoimport after other imports, leaving current import XXX in place.

When one types "import XXX" (XXX is an existing class or module) amongst other imports, then press tab to accept a suggested import, the AutoImport module adds auto import entry after other imports, leaving current "import XXX" text where the user typed it. The user has to manually delete this duplicate and move the auto-import to the desired location where the text was originally typed.

Add option to disable removeFileExtenion

Thank you for this great extension!

Browsers have added support for import statements with <script type="module">, but do not (or rather, Chrome does not) support omitting file extensions.

I find this extension very helpful in looking up filepaths, but I always need to go and add "js" to the import statements it adds. :)

Don't work with Prettier extension

When I go to save any *.jsx, *.js, or *.py file, a notification appears like:

90684088-6f26d900-e21c-11ea-987b-86ec27c30189

and never goes away. the file does not save. If I wait long enough, VSCode entirely hangs and I cannot interact with it

[Bug] Semicolon option only import one lib

The no semicolon option only works in the first import.

Steps to reproduce

Tested on an react-native project (inside an empty .js file) with the following autoImports Settings:

{
  "autoimport.absolute": false,
  "autoimport.autoComplete": true,
  "autoimport.doubleQuotes": false,
  "autoimport.filesToScan": "**/*.{js,jsx,ts,tsx}",
  "autoimport.higherOrderComponents": "connect|withRouter",
  "autoimport.showNotifications": false,
  "autoimport.sourceRoot": "./",
  "autoimport.spaceBetweenBraces": true,
  "autoimport.semicolon": false
}
  1. Type View and the intellisense will suggest the import, use it to generate:
import { View } from 'react-native'

View
// Now start here
  1. Type Button and the intellisense will suggest the import, use it. It will not import the Module (if you enable the Semicolon and start over, it will work as expected).

Ordering with IntelliSense completions?

Is it possible for the autoimport entries to be added after the IntelliSense completions?

For example, I have an enum Month with a value April. When I type "ap", the first entries listed are from autoimport (see screenshot), because it's ordered alphabetically. But it's obvious that I want to see only the fields belonging to Month, or that at least they should be listed first.

screen shot 2019-01-06 at 13 17 17

[Bug] Not working with all React Native modules / components

I was able to configure the plugin to work with an React Native Project, but it fails sometimes and doesn't recognize some modules (ScrollView, DatePickerAndroid, etc)

Steps to reproduce

  1. Configure React Native CLI
  2. Create an React Native project: react-native init AwesomeProject
  3. Open your project with VSCode and create an JS file for tests (Test.js)
  4. Use the following code for tests
import React, { Component } from 'react'
export default class User extends Component {
    render() {
        return (
            //Start HERE
        )
    }
}
  1. Type <View and do CTRL+SPACE. the intellisense will not suggest the auto import (it will if you do not include the < before View)
  2. Starting over,
  • type <View, then SPACE (to hide the intellisense)
  • then BACKSPACE to delete the inserted space and return the cursor to the <View
  • Type CTRL+SPACE to open the intellisense. Now it will suggest the auto-complete
  1. Now, let's try to import another module (ScrollView). Starting over, type only ScrollView and after CTRL+SPACE. The intellisense will not find or suggest the import, but it exists in the react-native lib

Slows down Vim plug-ins during hot reload of Next JS project

I have a Next JS app (based on this template) and I have the Vim plugin enabled. Whenever the application is hot reloaded (basically, whenever I save a file while it's running), there is a 3-5 second delay before I'm able to navigate around in my code with Vim. The keystrokes are remembered but take some time before they kick in.

I've seen this behaviour in both the Vim plugin and the NeoVim plugin. When I disable the Auto Import plugin, all is well again and there is no delay in the navigation.

Remove unused?

It'd be nice if this came with a hotkey to clear out unused imports as well.

Add option to omit semicolon

Standard ESLint gives an error for unnecessary semicolons at the end of the line. It would be great if there's an option to omit them.

imports are being added with \ instead of / for path separator

I just installed this plug and the first time I used it, it added this import:

import { AppearanceService } from 'src\api\Services\AppearanceController';

notice the wrong kind of path separators. I am running on windows, but those separators need to be /, not . I don't see a config option to change that. I must have done something wrong when I installed it or something. I would have thought that everybody would be pointing this out.

high memory causing stuck

After testing, the memory usage of this plug-in on my computer often soars, causing vscode to get stuck

my Hardware info:

 Model Name: iMac
  Model Identifier: iMac19,1
  Processor Name: 6-Core Intel Core i5
  Processor Speed: 3 GHz
  Number of Processors: 1
  Total Number of Cores: 6
  L2 Cache (per Core): 256 KB
  L3 Cache: 9 MB
  Memory: 16 GB
  System Firmware Version: 1916.40.6.0.0

Prettier Format: FormatOnSave takes a long time

When we install this auto-import extension, the Prettier - Code formatter starts hanging. The prettier format takes a long time on save to format the code. When I disable this auto import extension then everything works fine.

Extension disables the auto update file location on move

When drags a file to some other folder, VS Code by default update the absolute path of that file from all of the files using that. But when this extension is enabled, the default behavior is gone. I am using the latest version VS Code and the extension as well.

Add extra semi-colon setting

My project using standard.js on ESLint. So, I always need to remove ; by myself after imported. That would be great if there has configurable for non-semi-colon.

Please advise how to implement similar functionality in the application

@NuclleaR Thank you very much for the plugin.
I've been using it for a very long time.

Now I want to implement similar functionality in my cli application.
And I want some advice, because I have not managed to understand everything in the code.
I have some questions.

  • Do you collect all names of interfaces and types by yourself manually?
  • Do you insert collected types by yourself or using vscode or tsserver?

If you find the time to answer it, I will be very grateful to you.
Thank you.

typescript and react project hang

i was debugging using bisect, and finally found this extension causing save, eslint format that caused it to hang.
1st save or format file works but slow. second and subsequence save seems to trigger the delay and lagged and takes forever to load

Use special resolve paths?

Hi,

Thanks for this extension!

Jetbrains products automatically use the special paths configured in webpack. Is it possible for this extension to do that?

For example:

{
  resolve: {
    alias: {
      '@src': path.resolve(__dirname, '..', '..', 'app/javascript'),
      '@types': '@src/types',
      '@images': path.resolve(__dirname, '..', '..', 'app/assets/images')
    }
  }
}

Instead of adding the import with ../../../components/..., Jetbrains products add it as @src/components/.... This is very useful when moving files around, as the imports don't have to be changed.

vscode getting stopped

I was working with vscode, but today suddenly the vscode editor works to slowly and after being get slowed,
vscode window close functionaliy and clicking any buttons, or folders/files in vscode is not possible.

It was working very fine previous days....
Could you please find any solutions to fix vscode getting slow or stopped?
Is there any reasons for that?

Limit suggestions by a folder

Hi,
Is there any way to limit the suggestions by a folder? We have a monorepo with many top-level folders for each of our projects and want to ignore suggestions related to other projects.

Our structure:

/a // project 1
-- a.js // exports foo
/b // project 2
-- a.js // exports foo
-- b.js

when we want to import foo in b.js, we have suggestions from both a/a.js and b/a.js, we want to only see suggestions from b/* in this case.

High CPU on Linux

When running a build of my project on Linux, this extension (and each of the extensions it's forked from) starts hundreds of ripgrep processes.
If I simply disable this extension I see no hammering of the CPU.

Here is an example of one of the processes (they all have the exact same parameters) of which I believe it probably starts one process per file created during build.

benkais+  2783  4.2  0.1  37980 16768 ?        Sl   15:23   0:00 /opt/visual-studio-code/resources/app/node_modules.asar.unpacked/vscode-ripgrep/bin/rg --files --hidden --case-sensitive -g **/*.{js,jsx,ts,tsx} -g !**/node_modules/** -g !**/.git -g !**/.svn -g !**/.hg -g !**/CVS -g !**/.DS_Store --no-ignore --follow --no-config

The extension is literally unusable on Linux with this flaw. For reference this issue isn't present when running the build under Windows.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.