'refactor' move files in VSCode - es6 - ecmascript-6

If I move ComponentFoo.js from folder X to folder Y, than a bunch of import statements break. Looking into this it seems there are many solutions for typescript, but what about js / es6? If I move a file in the editor, it should find all the import statements and update them to the new location. Is this possible?

Old post, but this might help some Googlers. This feature can be enabled and disabled in User Settings. For Javascript and Typescript, it's called "Updated Imports On File Move".
I had apparently disabled it and just figured the feature was broken :X

VS Code has built-in support for this for both javascript and typescript since VS Code 1.24.
For JavaScript specifically, you need to make sure VS code's language support can find all the references to the file so that imports referring symbols in that can be updated properly. Definitely create a jsconfig.json for your project, and also consider enabling semantic checking for JavaScript so that VS Code shows when imports are not being properly resolved
If your project is configured properly but files are not being updated, make sure you are running the latest VS Code insiders build and report an issue if it still doesn't work

for flutter developers you should move files one by one. vscode doesn't support multi file moving with refactor yet.

Just use IntelliJ. It handles all kinds of refactoring perfectly. I'm a huge fan of VS Code, but refacotoring is definetly not one of it's stengths. Some imports don't get detected, and the imports can get modified in a weird way. For example, I had an import like this:
import { myStore} from 'src/common/stores/myStore';
When moving the file of myStore.ts to a different folder, VS Code constructed this bull**it:
import { myStore} from 'src/common/composables/myStoreStore';
The line above is no typo!
Btw I'm using vetur, maybe thats causing it, I don't know ...

Related

Always include the latest version of custom Google Drive library

I'm trying to link a custom library to a document that will be copied and shared with many people. I want to have all documents link to the latest version of the library, so when I modify the library I don't have to access all the documents to change the link.
This is the scenario:
I created a simple single function library (e.g. library TestLib, function foo()), and saved a first version of it. Then I've created a SpreadSheet with a script that generates a user menu that calls function TestLib.foo(). I've linked version 1 of the library to the script. Now I want to make several copies of the document, one for each people who will need it. The problem is that these documents are linked to version 1 of the library. If I made a change to the library and create a version 2, I have to manually re-link all documents to the new version. That's gonna be lot of work...
Is there a way to have the script to always link to the latest version?
NOTE: the library project is shared in read-only mode (people won't collaborate with the code. They just call foo() from the menu when needed).
Thank!
MIX
I made a new test, trying to overtake the version "limitation" problem.
The idea is a little complicated, but promising. The spreadsheet calls a function in library LinkLib: this library will be saved in a single version and the source code will never modified. The library function simply calls a function on another library (MainLib), whom source code can change over time. Spreadsheet doesn't need to change the version of the linked library (there will never be new version of BaseLib source code), while BaseLib can change the version of MainLib linked if I made changes in MainLib's source code..
The problem is: changing the version of a linked resource is treated as a source code modification. So you need to save a new version of BaseLib to actually use an updated version of MainLib's function.
Hope this mess is somewhat clear...
It makes sense that the described version management behave like this. But damn, I'm still stuck with this problem...
this is possible but with a risk. simply use "development mode" for all documents using the library. whenever you update the library it will include the new code automatically.
the risks are that you will have to be careful to never save an intermediate/partial change as all changes need to not break anything. this can be tricky and is best to have a separate library copy to use when making and testing changes. once tested you may copy all files and "save all" together so the script doesnt have partial saves.
basically you lose the development facilities of using versions.
read more about library development mode in the official docs.

phpstorm unresolved function or method $()

I have the following problem: phpstorm do not recognize jquery methods and here and there I see
Unresolved function or method $()
This was bugging me for sometime but finally I tried to get rid of it with File->Settings->JavaScript->Libraries and adding jquery as a global / project.
My library setup looks like this:
But is has not changed anything. I still see those pesky notices. Does anyone know how to get rid of them?
There is a really stupid workaround,
Download the Library (in this case jQuery) from inside the IDE itself.
Open up settings (Ctrl + Alt + S on Linux)
Navigate to Languages & Frameworks -> Javascript -> Libraries
Click Download and choose jQuery
Hopefully the errors will vanish
EDIT:
After running the IDE through Fiddler, I realised this only solves the problem because of the version the IDE downloads.
So, the correct workaround is to Add older, non-AMD jQuery versions as a Global scoped Library and add the latest one as a Project scope library.
The latest non-AMD versions are:
1.10.2 for 1.x series. And, 2.0.0 for 2.x series.
I had the same issue with version 1.11.2, and resolved it simply by adding the uncompressed version into my js folder.
Just copy the uncompressed version of jQuery into your project folder.
you don't even need to import it into your project, just copy it to javascript folder.
The jQuery v1.11.0 shows exactly the same behaviour here as well. At the same time previous version 1.10.2 works fine in IDE (no warnings).
I think it has something to do with "AMD-fy jQuery source" ticket (http://bugs.jquery.com/ticket/14113) -- looks like IDE has some issues figuring out this style.
If you wish (and can) -- roll back to jQuery v1.10.2 (which is like half a year old, which means it's stable and still good to use).
Hopefully IDE will be able to properly parse this new jQuery style in next release.
Actual ticket: http://youtrack.jetbrains.com/issue/WEB-10908
If you import both 1.11.0 and 1.10.2 in phpstorm it will be resolved
You don't have to rollback your project.

Sails.js asset management and referencing

Sorry for the noob question but I'm trying to start up a new application with Sails and include my assets. I'm using Bower to manage my packages for things like Bootstrap and JQuery. I had a read of this question and added a .bowerrc file which is now installing my Bower components to /assets.
I'm now confused as to how I should proceed to add these files into my project. It seems as though I can't just do a <script> tag in the header as I'm used to because it's giving me a file not found. Reading through the sails documentation it seems like Grunt should be creating a .tmp/public/assets folder in my project, but whenever I run sails lift and go to .tmp/ there is nothing in there.
I also read in the documentation that I should be using some kind of asset injection, I tried adding this to my HTML and it seems like it doesn't do anything.
My other question is around how I go about referencing images in my HTML. Obviously I can't just do something like src='assets/images/image.png, how should I go about this? Is there something really obvious that I'm missing?
Sails use grunt tasks to do lot of things during lift and build. You can get much better look how everything work if you take some time and check what is inside Gruntfile.js from root of your sails project.
About your specific question here is some information:
- from sails docs: "In order to take advantage of asset injection, minification, and concatenation you must put your assets in folder under assets/linker". This exactly mean that everything what you will put inside assets/linker directory will be affected by grunt tasks during lift. It mean that all files/directories from linker will be copy to .tmp/public and also some of that files will be processed before saved to .tmp/public.
- About adding tags. If you take a look at Gruntfile.js you will find this variables: var cssFilesToInject = [...] and var jsFilesToInject = [...] which contain files that will be automatic added to layout header during sails lift.
- About your 'other question', yes you can do something like 'src='linker/images/image.png' if you move that files to linker directory (assets/linker).
I hope this help :).

How to setup limeJS in a totally offline workspace

I'm trying to setup limeJS, the issue is the Internet connection is a problem. I had closure library, box2d, closure compiler and closure templates downloaded separately as .rar files, but I can't find a guide anywhere to set it up like this, everyone just uses(and with reason!!!) the python bin/lime.py init command to get it working. I managed to figure out(yay!) how to setup box2d and closure library but what about the other two?
My laptop is running 64 bits Windows 7. Any help appreciated
All I need is an advice on directory structure, like where to drop the compiler.jar and soy templates .js files, so that when I run the update/create command it doesn't try to download the compiler or templates like it does right now.
I got it working, after taking a quick look at the lime.py file it told me everything I needed, for example both the SoyJs templates file and the compiler need to be in the /path/to/lime/bin/external folder and for example, the lime.py file was expecting a compiler file named compiler-dateOfLatestCompiler.jar instead of compiler.jar.
In general, If you have LimeJS built up in one machine using Python and all, you can just copy paste the whole package anywhere you want and use it just as ususal.
You don't need network once you have all the files/codes for Lime is downloaded.
Infact, you dont even need python for normal development tasks(Python is required to build your js file once you complete development though)

Flare and ActionScript error

I am trying to compile this sample program but I am brand new to Flare and ActionScript. Here is the DependencyGraph example that I am trying to compile: http://flare.prefuse.org/apps/dependency_graph.
The error I am receiving right now is:
Access of unidentified property App
Are there certain packages or project files that I will need to import or add to the source code in order to fix this?
Looks like you need to grab this class as well:
http://flare.prefuse.org/src/flare.apps/src/flare/apps/App.as aside from that it looks like the imports are all coming from packages in flare and should be included in the flare swc file.
Edit
Okay so starting from scratch I was able to get Flex 3.4 SDK playing nicely with the flare demos:
Download zip http://sourceforge.net/projects/prefuse/files/flare/alpha-20090124/prefuse.flare-alpha-20090124.zip/download
extracted flare.apps to my desktop and build/flare.swc to my desktop
In FlashBuilder/Eclipse import a project (existing project) select the flare.apps folder on the desktop.
replace the existing library reference to bin/flare.swc with the one from the desktop. When I imported the project it had in the project properties->ActionScript Build Path I selected the bin/flare.swc entry it had and hit remove, then hit add swc and browsed for the one extracted to my desktop from the flare.zip.
Compile/Run
That all worked great with Flex 3.4 (Flare is out-dated if you haven't noticed). Upping my SDK to 4.6 I had to replace JSON (ambiguous due to a new one in the default package) with com.adobe.serialization.json.JSON. With Flex 3.4, did you see any errors relating to JSON? I don't have 3.4 on my system so I am using 3.6 right now and see many errors regarding the ambiguity of JSON. With regard to 3.4 I had no JSON errors, think the Class may have been introduced around when 3.6 was put out so that makes sense too... the issue is if you import JSON from some package but then it also has JSON in the default package, it doesn't know which one you want to use, if you use the fully qualified class name wherever you were using the shortened version it will remove the ambiguity so where you had JSON.decode just replace with com.adobe.serialization.json.JSON.decode, believe the one in the default package is the new one and doesn't match up to the old one's interface (method names) 100%.
After building with 4.6 it's a mixed bag... I see the loading bar and all the lines between dependencies but not seeing the labels themselves, my guess is something to do with the change in the font/text rendering engine between versions is making a difference though I'm not sure immediately how to resolve that. No errors compiling/running though.
Edit 2 good deal just had to add this to the font embed for it to work in 4.6
,embedAsCFF='false'
[Embed(source="verdana.TTF", fontName="VerdanaCust",embedAsCFF='false')]
Let me know if you try out these steps and still have issues, or if this helps you resolve your problems.
Edit 3
Also added you on my gmail alternatively can chat on SO directly to keep any relevant information connected to this QA