DEV Community

Cover image for What's new in P42? Winter 2022 Summary
Lars Grammel for P42

Posted on • Edited on • Originally published at p42.ai

What's new in P42? Winter 2022 Summary

There have been many changes to the P42 JavaScript Assistant for Visual Studio Code in January 2022:

User Interface

Suggestions Sidebar Panel

The P42 sidebar now contains a panel with refactoring suggestions for the content of the currently active editor. You can get more details on the suggestions and apply them directly from the panel. With P42 Pro, you can also apply all safe refactorings with a single button click.

P42 Refactoring Suggestions Sidebar Panel

Mass Refactoring Safety Warnings

When running a mass refactoring, it is crucial to verify the changes before committing. The mass refactoring output now contains the list of changed files and any safety warnings for refactorings that have been applied to make this easier for you to spot potential issues.

Configuration

Refactoring Suggestion Settings

Are there refactoring suggestions that you think should be warnings or errors? Do you want to turn off some hints that annoy you?

With the new refactorings suggestions settings, you can set the diagnostics severity to different levels and turn off refactoring suggestions.

P42 Refactoring Configuration in VS Code Settings

Path Exclusion Patterns

Repositories are often complicated, and there can be many files that you want to exclude from P42 mass refactorings and refactoring suggestions. Common examples include node modules, distribution and output files, configuration files, and 3rd party code that's checked into the repository.

With the new excluded path patterns, you can configure a list of path globs in the p42.toml file that should be excluded. Here is an example:

excludedPathPatterns = [
    "**/node_modules/**",
    "**/dist/**",
    "some/other/directory/**",
    "**/generateConfig.js"
]
Enter fullscreen mode Exit fullscreen mode

Refactorings

Working with Strings and Template Literals

Working with Loops

Simplifying and Removing IIFEs/IIAFs

Immediately-invoked function expressions (IIFEs) and immediately-invoked arrow functions (IIAFs) are common in older code to hide state in closures, secure the scope of var declarations, alias global variables, and access loop variables from async functions.

With the introduction of the block scoped let and const in ES6, many use cases have become obsolete. P42 can help you remove older IIFEs safety.

Modernizing Lodash Usages

With the introduction of various collection helpers and new syntax in ES6 and more recent JavaScript versions, many Lodash functions have become partially or fully redundant.

In January, several refactorings that help you modernize older Lodash code have been added to P42 Pro:

Those are all the new features and updates from January 2022. If you want to know about new features as soon as they are published, you can follow @p42ai on Twitter.

Happy Coding!

Top comments (0)