ReSharper 6 enhances the JavaScript experience

We already mentioned some of the benefits that ReSharper brings to the table when it comes to JavaScript development previously. In this post we are going to have a more in-depth look at some of the features.

Pimping jQuery

In addition to support for JavaScript, ReSharper 6 also provides certain functionality specific to jQuery.

Code Completion for Selectors

When working with jQuery selectors we often need to lookup certain DOM elements or CSS classes in order to operate with them. This can result in a back-and-forth between the code we are working on and looking up of a specific element. ReSharper 6 facilitates these cumbersome operations by providing code completion for selectors:


This completion is invoked by typing # between the quotes, where as if we were to type ., we’d get:


This completion is available anywhere we a selector is required.  Of course if we merely want to select a specific type of element, we also have completion:


Extending jQuery extensions

One of the benefits of jQuery is the ease by which we can extend it to add our own functions and methods. ReSharper enhances this experience by providing completion also for custom extensions. For instance, if we were to write a new extension:


we now have myFoo available as a method of jQuery:


Much in the same way, if we want to extend an object:


we have:


Importing File References

Out of the box, Visual Studio requires a special comment to be added to script files to provide support for IntelliSense:


With ReSharper this is not required. If however, it is included, ReSharper will then limit the scope of Intellisense to the reference added. This reference can be provided by directly typing it in, in which case ReSharper offer completion:


as well as providing quick-fixes when errors are detected in paths:


Creating from Usage

Similar to C# and VB.NET, we can now also create JavaScript code based on usage. For instance, let’s say we write some code that calls a specific function named getInterval that does not yet exist. ReSharper prompts us to create a local function:


generating the code for us, providing us the same ability we have in C# to iterate through parameter names etc. The same applies to variables:


as it does to creating parameters and properties; once again, making the whole development experience a bit smoother.

Last but not least, ReSharper also provides the ability to create jQuery extension methods from usage:



Certain refactoring operations are now available in JavaScript. Firstly, in combination with Create from Usage, we can now easily add an extra parameter to a function call and have ReSharper offer to create it for us:


Introduce Variable is another refactoring option available:


And last but not least, Renaming:


ReSharper is smart enough to handle the scope of the renaming outside of the current local scope, prompting you always with the option to fine-tune certain renaming’s.

Code Clean-up and Rearranging.

In a previous blog post we mentioned briefly the code formatting options for JavaScript. These have now been extended and better organized. We can fine tune Lines Breaks, Braces Layout as well as Space via ReSharper | Options | JavaScript | Formatting Style. Below are the options for the newly added Spaces:


Running code-cleanup on JavaScript files is of course now also possible:


Also, out of the box, we provide certain filters, both in clean-up and analysis, such as those with min.* extensions. These can be changed in the options dialog, albeit it’s not highly recommended.


Rearranging Code

You can now rearrange code which includes moving parameters around, moving members up/down as well as arguments and object literals and arrays. All this is done using the same key combination as used in C# and VB.NET (Ctrl+Alt+Shift + Cursor Keys).

Code Inspections

JavaScript is a dynamic language. It has great advantages but can prove to be not the easiest language to work with, specially for novices. We’ve tried to ease some of that pain by providing code inspections, where possible. Among the many code inspections that currently are available are:

Syntax errors


Unused symbols


Dead code


Duplicate switch statements


Misuse of “this”


Accessing undefined global symbols


And this is just a few of the over 25 inspections that ReSharper supports along with their corresponding quick fixes. We believe that this will help remove some of the issues encountered at runtime, specially by newcomers.


Some of the other features provided for JavaScript are:

  • Configurable Naming Conventions: Much like C# and VB.NET you can define your own naming conventions.


  • Comments: Ability to comment and uncomment blocks of code as well as support for XML Documents.
  • Context Actions Settings: You can fine-tune which of context actions you want enabled.


  • Live Templates:  Support for Live Templates
  • Navigation and Find Usages: Navigation support as well as Find Usages for JavaScript members, some of which was already covered in a previous post.
  • Coding Assistance: Also covered in previous post.

All in all, we hope that some of these features allow JavaScript to become a language to that easier to learn, use and enjoyable.

ReSharper 6 is currently in EAP. Download it today and start playing with it. We’d love to hear your feedback.

One thought on “ReSharper 6 enhances the JavaScript experience

  1. Alejandro Melis


    The Resharper 6 RC recognizes the reference to a javascript file located in other assembly ?


    Best regards,



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s