Can Webstorm play nice with Chai language chains? - intellij-idea

I am using Mocha+Chai for a current Node.js project. My IDE is Webstorm 11.
Unfortunately, it seems Webstorm has no way of figuring out how language chains in Chai's should/expect are supposed to work. The following is commonplace:
I have tried explicitly setting both Chai and Chai-DefinetlyTyped as libraries for my project via Settings->Javascript->Libraries, but this does not resolve anything.
For the sake of tool support, I have considered dropping expect/should for assert instead, as this works perfectly. However, I very much prefer the style of expect/should, so it would be amazing to see a solution to this.

Problem is caused by weird dynamic way these chains are defined. As a workaround I can suggest using chai.d.ts:
Open "Settings | Languages & Frameworks | JavaScript | Libraries"
Click "Download..." button and select "TypeScript community stubs"
Find "chai" and click "Download and Install".

Related

How to reformat a Vue.js component in VS Code?

I'm using Visual Studio Code to code a Vue.js component and need to reformat the code of that component.
I did not find any built-in formatters, and the first choice for a plugin was vue-buetify which informs after installation that
There are many bugs in the extension, please do not use it, the better choice is vetur
I then tried Vetur by installing it but there is no place where I see an option to beautify the code currently in the editor. The Shift + Alt + F command has no effect.
How can I actually beautify (reformat) the code for a Vue component?
I've been fiddling with formatting quite a bit since my previously working project stopped formatting one day. Here's what I think the current state of the art is:
Use extensions vetur and prettier (specifically, esbenp.prettier-vscode Prettier - Code formatter). (You get these preinstalled by Vue.js Extension Pack esbenp.prettier-vscodeand others.)
Vetur is the (current) mandatory default tooling for vue. Accept no substitutes.
Prettier doesn't support .vue files per se, so that filetype is disabled by default: https://github.com/prettier/prettier-vscode/issues/338.
But Vetur understand its limitations and instead delegates formatting of individual sections of the .vue file to a potentially different formatter. By default, though, it delegates everything other than HTML sections to Prettier. https://vuejs.github.io/vetur/formatting.html. It disables formatting for HTML sections.
Vetur developers are down on js-beautify-html, although it is still apparently functional: https://vuejs.github.io/vetur/formatting.html. And they don't make an alternative recommendation at this time.
Prettier support for HTML, which would be the obvious choice if only it existed, is a long, sad story. Currently (May 2018), prettier formats HTML as JSX. Many subtleties are mentioned, but one issue that I have grasped is that JSX converts begin/empty/end tags to empty tags, e.g to . Apparently React and (I believe) Vue, do not like this, hence vetur disables Prettier for HTML.
So I'm going forward with enabling js-beautify-html in vetur settings, hoping for the best and keeping my eyes peeled. But I'm such a superficial coder that I may never trip over its known issues.
In 2022, the situation regarding formatting Vue files regaled in another answer has vastly improved.
Vetur is still the de facto solution for managing .vue files in VS Code, but in the time since this question was asked, Prettier added full support for them (and HTML proper). This means you can format them using Prettier without Vetur if you so desire.
Note that Vetur does not support VS Code's "Format Selection" functionality, even though Prettier does (for a small set of languages):
Vetur only has a "whole document formatter" and cannot format arbitrary ranges. As a result, only the Format Document command is available.
The Format Selection command does not work.
If you do decide to use Vetur, you shouldn't need any other extensions to get formatting to work, as the extension comes bundled with all of its available formatters. As long as you have the extension installed and enabled, formatting with the "Format Document" command or Shift + Alt + F should work out of the box.
Vetur's settings allow the user to configure which of its available formatters is used for each language it supports (Prettier is the default for all but Sass and Stylus). The formatters can also be toggled off per language, or entirely, if you prefer to use some other formatting solution instead.
If you have installed the Vetur extension on VS Code,
Go to the VS Code extension area.
Find Vetur and select the gear icon to enter settings of Vetur.
Scroll down until you find
Vetur › Format › Default Formatter: JS
Default formatter for <script> region
Select pretter-eslint from dropdown menu
(if you don't see that option you can install Prettier extension).
Now you can see it formats your code automatically whenever you save.

How to automatically reload Clojure code?

How to automatically reload Clojure code?
I have watched the presentation. And in there they use some hot swap Clojure technology that reloads code whenever changes are made into source files. I can run the code, but I can not observe the effect of auto reload. How is it possible to reload the code?
the source code.
There are many ways to reload code, depending on the situation:
Emacs/CIDER shortcuts to reload a file. Probably Rich is doing something similar. Also see this: How to reload a clojure file in REPL
watch files and reload the code (figwheel for frontend development does that, test plugins as well as CIDER shortcuts specifically for running tests, boot has a watch task...)
a middleware for the web server you use (ring for example has ring.middleware.reload/wrap-reload for this, pedestal comes with one as well, other webservers like yada play well with component)
a component workflow works also, there is an example of an auto-reloadable system with holy-grail
(I didn't fully re-watch this video, but these notes are from my observations after skipping through the video and making educated guesses)
From what I re-watched of this video it looks like Rich is evaluating the code in a running repl. This allows him to change the code, evaluate it, and see different behavior.
Many editors have support for evaluating code in a buffer in a Clojure repl. Here is some documentation on using CIDER with Emacs to get to interactively play with your code.
Unrelated to the video in question, if you are using ring for web development. You can use the wrap-reload middleware to have your code automatically reloaded when a file has changed and a request hits your web app. This is extremely useful when developing a Clojure web application.
For automatically reloading and running your clojure.tests I recommend lein-test-refresh. It is a Leiningen plug-in that monitors your project for file changes and when something changes it reloads and runs your tests. If you have tests for your project this greatly speeds up development.
Use mount to manage the starting and stopping of your components. For example in a backend web app, you'll want to startup the db before you start the webserver probably.
Then in emacs you can have:
(defun cider-repl-refresh ()
(interactive)
(save-some-buffers)
(with-current-buffer (cider-current-repl-buffer)
(goto-char (point-max))
(insert (concat "(require 'clojure.tools.namespace.repl) "
"(clojure.tools.namespace.repl/refresh)"))
(cider-repl-return)))
If you are not super fond of Emacs (I love Emacs, but hey not everybody does) LightTable is a very nice option for Clojure/ClojureScript interactive programming too.
For developing ClojureScript (Clojure that compiles to Javascript) LightTable and Figwheel are a really nice pair.
In my opinion LightTable has some advantages against Emacs (I never got cider to work perfectly with ClojureScript) for the webdev side, LightTable is basically a specialized version of Chrome, because it is built on top of Electron.
Check this documentation on the Figwheel GitHub page: Running Figwheel with LightTable:
If you are using Cursive IDE in IntelliJ, there is a special REPL tool which you have to setup to get the functionality you are looking for. It has many features vs. "lein repl" in a terminal window.
Full tutorial here: https://cursive-ide.com/userguide/repl.html
However, its very easy to setup a default instance:
Right click project.clj/deps.edn -> "Create Repl for...". Default settings are fine. Hit ok/apply.
Right click project.clj/deps.edn -> "Run Repl for..." (a repl window will open)
See Tools->Repl for a list of commands, such as:
switch to repl window: Ctrl+\
reload current file in repl: Alt + Shift + L
send function defn to repl: Alt + Shift + M
... and more
In addition you'll get full code completion, syntax highlighting, etc. when writing in a REPL.

Using MXUnit or is there another way to display coldfusion output using Intellij IDEA 15

I'm loving IntelliJ because I also work with MySQL and the integration into one UI is great. Seems that IntelliJ works nicely with ColdFusion as well. I'm just hoping to successfully use MXUnit, but I seem to be getting an error upon testing. My main goal is just being able to display the output directly in IntelliJ instead of outputting in a browser.
My test site path: /Applications/ColdFusion11/cfusion/wwwroot/Test/test.cfc
Error http://localhost/mxunit-launcher.cfc?method=executeTestCase&componentName=test
Seems like I have to add in a mapping, maybe in CF Admin, because the path and web path don't match but I haven't done that before if that's the case. Here's a screenshot of input in IntelliJ, and the output at the bottom of the screenshot when running the debugger:
Thanks for any feedback on what I might be missing.

Code assist - Sencha Touch

I am following this tutorial http://vimeo.com/album/1573372/video/37212149
It seems that there is a way to type "xmodel" and have a standard model's code generated automatically. I am using Webstorm IDE - is there a way of doing this in it, and any configurations I can import?
Thanks
Seems 'Live Templates' is the feature you refer to - it allows expanding abbreviations into code snippets. See http://www.jetbrains.com/webstorm/webhelp/live-templates.html, http://davidtucker.net/articles/live-templates-phpstorm-webstorm/
WebStorm doesn't come with predefined live templates for Sencha, but you can easily create them yourself or search the web for existing templates. See ST2 Power Tools, for example

Intellisense for Objective-J?

My editor of choice for Objective-J Cappuccino development right now is Sublime Text 2. Unfortunately I haven't had any luck finding an Objective-J intellisense autocomplete plugin. It seems it should be doable, since Objective-J does have (optional/pluggable) types. So I think a plugin could definitely parse the code to find the expected type of the object you're trying to autocomplete on, and then look up its method list. Does anyone know of any other editors that support intellisense for Objective-J?
They is only one intellisense plugin for vim available.
You can find a little example video on youtube :
http://www.youtube.com/watch?v=lJrOcHxq6vc
Plugin:
https://github.com/nanki/vim-objj
For Sublime Text 2 you can try https://github.com/aparajita/Cappuccino-Sublime, although it is not that "intelli" as vim plugin.
After installing you should be able to get autocompletion using Ctrl+Space.