Tools like JSHint and JSLint are increasingly popular nowadays. Their inspections are great, but sometimes you want not just to know where the error is, but also to be able to fix it, and you want to see the error as you write code, not as a post-build step. ReSharper is here to help: we have already implemented several inspections similar to JSHint, for example, the variable and function naming inspections and inspections for using undeclared global variables, and we offer quick-fixes for them. ReSharper 9 offers additional JSHint-inspired inspections and quick-fixes for them:
- Assignment inside conditional expression, with a quick-fix to change
===.Just in case you do want to perform assignments in conditional statements, ReSharper gives you an option to indicate such expressions by wrapping the assignee with an extra set of round braces. There’s even a fix for this:
- Constructor call not used or possibly used for side effects — we provide a quick-fix for replacing it with a function call.
- Caller/callee usings (warning; error in strict mode).
- Coerced usage of equals (use of
!==) with a quick-fix to perform appropriate replacements.
- Extending/overwriting prototype of native object
- Variable/function used before it is declared with a quick-fix to normalize declarations.
- Variable/function used outside of block where it is declared, again with a suitable quick-fix.
- Local function is redefined later
- Incorrect argument comparison with
typeofexpression with a quick-fix to replace with the correct value.
- Closure on a variable modified in loop of outer scope
- There is no
.hasOwnProperty()check in a body of
for inloop — this will cause an enumeration of prototype properties. ReSharper provides a quick-fix to surround the body with a
Also, ReSharper supports JSHint’s
/* global ... */ annotations for global variables:
In addition to the above features, ReSharper 9.1 EAP (which you can download here) comes with initial support for ECMAScript 6. This includes support for destructuring, let and const declarations, template strings, lambdas, and a lot more. This support is early-stage, but we do plan to fully support ECMAScript 6 in due time. Check out the EAP for how these features are shaping up, but do bear in mind that VS2015 CTP will highlight correct ECMAScript 6 code as errors in many situations. We just have to give it a bit more time to catch up.
Subscribe to Blog updates
Creating Custom AI Prompts
AI has swept through the software development industry like a wildfire. So people want to learn how to best use AI in their day to day tasks. In this post we’ll take a look at how to write custom prompts for use with the JetBrains AI Assistant in ReSharper and Rider so you can make the most of AI.&n…
12 Debugging Techniques In JetBrains Rider You Should Know About
Twelve must know debugging features in JetBrains Rider every developer should know.
Interceptors – Using C# 12 in Rider and ReSharper
Welcome to our series, where we take a closer look at the C# 12 language features and how ReSharper and Rider make it easy for you to adopt them in your codebase. If you haven’t yet, download the latest .NET 8 SDK and update your project files! In this series, we are looking at: Primary …