The P42 JavaScript Assistant adds 85 automated refactorings and code assists for JavaScript, TypeScript, and React to Visual Studio Code. Write modern, clean, and concise codeEdit Code FasterManually editing your code can be cumbersome and error-prone. With the JavaScript Assistant, you can use fast, automated code assists and refactorings to modify your code on a structural level and focus on what change you want to make, not on how to type it in. Learn Modern JavaScriptJavaScript and its ecosystem are rapidly progressing. The JavaScript Assistant shows suggestions for using up-to-date JavaScript syntax and APIs so you can write clean, modern code without worrying about the latest changes to the language. Refactor SafelyRefactorings, especially those that are performed manually, can easily break existing functionality or introduce bugs. The JavaScript Assistant automates refactoring steps and analyses the safety of potential refactorings, so you can refactor with confidence and know what to consider to avoid unnecessary breakages. DocumentationYou can find the actions in the quick fix and refactoring context menus. They depend on the cursor position, the selected text (if any), the source code, the language type, and any available type information. Underlining with three dots suggests beneficial refactorings that you can perform. The suggestion sidebar shows you recommended refactorings for your whole file. Keyboard ShortcutsSee also Documentation / Editor Integration / Keyboard Shortcuts. The P42 JavaScript Assistant introduces several context menus for different refactoring kinds:
There are also several helpful default refactoring context menus that are provided by Visual Studio Code:
The inline action can also be executed directly:
You can move code elements with the following shortcuts:
The smart shrink and expand selection shortcuts are essential for creating semantic selections that provide the right context when triggering refactorings:
Learn morePremium FeaturesDeveloping the JavaScript Assistant extension takes significant time and effort. To make continued development sustainable, some premium features and refactorings are only available in the Pro and Business plans: You can try P42 Pro 14 days for free. Code Assists by CategoryCode assists that belong to several categories appear more than once. Core RefactoringsVisual Study Code already contains basic refactorings such as Rename and Extract Function. The JavaScript Assistant adds additional refactorings or extended functionality such as safety checking:
Code Assists for Logical ExpressionsBoolean logic can be challenging to read, especially as expressions get more complex. The JavaScript Assistant provides several refactorings that can help you simplify and tease apart logical expressions to make them easier to understand:
Code Assists for Branching StatementsBranching statements such as if-else and switch are central elements in many programs. Restructuring them can increase the readability of your programs, often in combination with refactoring their conditions:
Code Assists for Arrays and LoopsJavaScript has several ways of defining loops and many array methods that work on the whole array. The JavaScript Assistant provides several code actions for converting between different types of for loops and for converting to more idiomatic array methods such as array.includes().
Code Assists for Functions and MethodsFunctions and methods are essential building blocks of any non-trivial program. The following code actions make it easier to work with functions, methods, and their parameters:
Code Assists for Classes
Code Assists for Strings and Template LiteralsText manipulation has become more powerful with the introduction of template literals in JavaScript. The JavaScript Assistant offers several code actions to help you work with text, be it strings or template literals:
Code Assists for Variables
Code Assists for Object and Array Destructuring
Code Assists for Syntax ConversionIt is often annoying to make small syntactical changes by editing text. Often more than one position needs to be edited, and the code is broken during the edit, leading to incorrect errors and auto-completions that get in the way. You can execute the following syntax conversions with code assists:
JavaScript ModernizationsThe Javascript ecosystem is progressing rapidly. However, it is hard to keep codebases up-to-date with the newer JavaScript features, and codemods are not always an option due to their significant churn and potential for breakages. The JavaScript Assistant supports both codemod-like mass code refactoring and more opportunistic code modernization for the following upgrades:
Code Assists for ReactIn React, components often contain JSX, a syntax extension for JavaScript. The JavaScript Assistant provides code assists that make working with JSX and React easier:
Lodash ModernizationsWith the introduction of various collection helpers and new syntax in ES6 and more recent JavaScript versions, some Lodash functions have become somewhat redundant.
Code Assists for Moving Semantic Blocks
Code CleanupsCode cleanups remove unnecessary code. Such code can result from code churn, e.g., by applying other refactorings, adding new features, or fixing bugs. The JavaScript Assistant shows hints and automates the cleanup for the following situations:
Other Actions
Report Bugs and Suggest FeaturesPlease report any bugs or feature suggestions in the JavaScript Assistant issue tracker. License & Used Open Source LibrariesSee DISCLAIMER.txt. |