• Stars
    star
    792
  • Rank 57,492 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automated refactorings for VS Code (JS & TS) ✨ It's magic ✨

🧙‍ Abracadabra

Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.

"Refactoring: Improving the Design of Existing Code" by Martin Fowler

All Contributors

Build Status

With Abracadabra, you can quickly and safely refactor existing code in VS Code.

VS Code ships with a few basic refactorings. Abracadabra supercharges your editor with:

  • 🎁 Much, much more refactorings
  • Shortcuts to trigger the most useful ones in no-time
  • 💡 Quick Fixes to suggest refactorings when appropriate
  • 🛠 Options to customize the UX to your needs
  • 💬 Refactorings that work with .js, .jsx, .ts, .tsx, .vue and .svelte files

Refactor Legacy Code in a snap! 👌

Abracadabra in action

Installation

  1. Click on the Extensions icon (usually on the left-hand side of your editor).
  2. Search for "Abracadabra".
  3. Find the extension in the list and click the install button.

List of available refactorings

We have 40+ automated refactorings such as Extract Variable, Extract Type, Flip If/Else, Move to Existing File, etc.

👉 Here's the full catalog of refactorings available

All refactorings are available through the Command Palette.

Some refactorings have default keybindings configured, but you can change that.

All other refactorings are available through VS Code Quick Fixes. You can access them by clicking on the lightbulb that appear next to the code 💡 or use the default shortcut Alt ↵.

Pro Tip: You can also disable the Quick Fixes you never use in VS Code settings 🔥 (look for Abracadabra)

Features that support refactorings

Besides refactorings, Abracadabra also gives you some extra features that are here to support refactoring work.

Highlight Identifiers

When working with Legacy Code, a very useful refactoring consists in extracting pure logic out of the I/O code that is hard to test (eg. HTTP calls).

To help you spot all the I/O bits in a chunk of code, Abracadabra can highlight them for you!

Feature Keybinding On Mac
Toggle Highlight Ctrl + Alt + H ⌃ H
Refresh Highlights Shift + Alt + H ⌃ ⌥ H
Remove All Highlights Ctrl + Shift + Alt + H ⇧ ⌃ H
  1. Put your cursor over an Identifier you want to highlight
  2. Press Ctrl + Alt + H

All references to this Identifier will be highlighted. The highlight will persist even when you modify the code.

To remove, either:

  • Put your cursor over a highlighted reference and press Ctrl + Alt + H again
  • Press Ctrl + Shift + Alt + H from anywhere, to remove all highlights

This is handy for marking I/O code when refactoring, but you can use it to highlight any interesting Identifier and its references. Here are a few typical use cases:

  • Mark all usages of a variable, to help you regroup them
  • Identify variables that are always passed together in function calls

Does it highlights new references automatically?

Say you have highlighted a variable. Now you add some more code that refers to the same variable.

It won't be automatically highlighted.

We could. But a naive implementation of this would constantly parse the AST of the code you are working with, which would probably affect your editor performances (not good).

One way to do it would be to toggle highlight over the reference once to remove the old highlight, then again to get the new reference! But that's annoying!

That's why you have a "Refresh Highlights" command. Hit Shift + Alt + H and references will be recomputed again for you!

Configuration

Setting Description Default
abracadabra.ignoredFolders Folders where it won't propose refactorings ["node_modules"]
abracadabra.ignoredPatterns Glob patterns where it won't propose refactorings ["dist/*", "build/*"]

For the glob patterns, read glob's documentation to see what you can filter out.

All refactorings that appear in Quick Fix suggestions can also be disabled in your VS Code settings 🔥 (look for Abracadabra)

Release Notes

Have a look at our CHANGELOG to get the details of all changes between versions.

Versioning

We follow SemVer convention for versioning.

That means our releases use the following format:

<major>.<minor>.<patch>
  • Breaking changes bump <major> (and reset <minor> & <patch>)
  • Backward compatible changes bump <minor> (and reset <patch>)
  • Bug fixes bump <patch>

Contributing

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Abracadabra.

Good First Issues

To help you get your feet wet and become familiar with our contribution process, we have a list of good first issues that contains things with a relatively limited scope. This is a great place to get started!

Contributors

Thanks goes to these wonderful people (emoji key):

Nicolas Carlo
Nicolas Carlo

🤔 💻 📖 👀 💬
Fabien BERNARD
Fabien BERNARD

🤔 💻 🎨
David
David

🐛
GUL
GUL

🤔 💻
Alexander Rose
Alexander Rose

🤔 💻
Tim van Cleef
Tim van Cleef

💻 📖
Tobias Hann
Tobias Hann

🐛 💻 📖
Jiri Spac
Jiri Spac

🐛
YuTengjing
YuTengjing

🐛 🚇 💻
delaaxe
delaaxe

🤔 💻
James Nail
James Nail

🐛
Nick Ebbitt
Nick Ebbitt

🤔 💻 📖
Oliver Joseph Ash
Oliver Joseph Ash

🤔 🐛 💻 📖
Alberto Xamin
Alberto Xamin

🤔
Sakumatti Luukkonen
Sakumatti Luukkonen

🐛 🤔
Sergey Klevakin
Sergey Klevakin

🤔 💻
Andrew Janian
Andrew Janian

🐛
leosdad
leosdad

🤔 🐛
Iuliu Pop
Iuliu Pop

📖 💻 🐛
Christina Braun
Christina Braun

💻 🐛
Zak Miller
Zak Miller

🐛 💻 🤔
Marcus
Marcus

🐛
Jonathan Boiser
Jonathan Boiser

🐛
Vlad GURDIGA
Vlad GURDIGA

🐛
Sam Hasler
Sam Hasler

🤔
Nicolas Favre-Felix
Nicolas Favre-Felix

🐛
Wout Mertens
Wout Mertens

🤔
Luke Harold Miles
Luke Harold Miles

🐛 🤔
Ikko Ashimine
Ikko Ashimine

📖
Viktor
Viktor

🤔
sumbatx15
sumbatx15

🐛 💻
j4k0xb
j4k0xb

🐛 💻
Ian Obermiller
Ian Obermiller

💻 📖 🤔
Emily Marigold Klassen
Emily Marigold Klassen

📖
Vitaly
Vitaly

💻 🚇 🤔
Alan Hussey
Alan Hussey

🐛
Kevin Coleman
Kevin Coleman

🐛
Roberts Slisans
Roberts Slisans

🐛
Josh
Josh

🤔
brunnerh
brunnerh

🤔
Jose Cabrera
Jose Cabrera

🤔 💻
Sebastian Schlatow
Sebastian Schlatow

🐛
jtwigg
jtwigg

🐛
Andy Bulka
Andy Bulka

🐛
Andrew Ash
Andrew Ash

📖
Artem Zhivoderov
Artem Zhivoderov

🤔 💻
Simon Holmes
Simon Holmes

🤔 💻
Ramunas
Ramunas

🤔
Simon Chan
Simon Chan

🐛
byron wall
byron wall

🐛
Jeroen van Warmerdam
Jeroen van Warmerdam

📖
Steve Beaugé
Steve Beaugé

🐛
Samuel Bronson
Samuel Bronson

🐛
Timon Jurschitsch
Timon Jurschitsch

💻
Leo Driesch
Leo Driesch

🤔
Romain Guerin
Romain Guerin

🐛

This project follows the all-contributors specification.

Contributions of any kind are welcome!

Alternatives

Building automated refactoring for JavaScript is not easy, and it takes time. Since this is a side-project, it doesn't get as much time as it should to cover everything you need.

If Abracadabra doesn't fit your need for something, here are the other extensions I recommend you check:

  • JS CodeFormer which is built by Chris Stead. Chris built the first JS refactorings extension in VS Code back in the days, so he knows his stuff 👍
  • P42 JavaScript assistant is a recent and impressive tool built by Lars Grammel. I had the opportunity to chat with Lars and we really think alike. The main difference is that Lars is dedicated full-time into building this. It's not open-source, but it may solve the problem you have 😉
  • JavaScript Booster is a popular extension that mimics Webstorm's UX for refactoring—which was a source of inspiration for Abracadabra. Worth having a look.

There are some things I think Abracadabra does better. Other things Abracadabra does worse. The goal with this extension is to provide automated refactorings that are easy to use and VS Code misses. If others are implementing them, I'm more than happy to recommend (and use) their tool!

Have a look, give them a try, use a combination of tools that work best for you.


License

💁 MIT

More Repositories

1

gitgraph.js

[ARCHIVED] A JavaScript library to draw pretty git graphs in the browser
TypeScript
3,018
star
2

trello-kanban-analysis-tool

💤 [Not maintained] Analyse Kanban metrics from a Trello board -
JavaScript
114
star
3

vscode-slides

👩‍🏫 VS Code as a presentation tool
TypeScript
61
star
4

hocus-pocus

VS Code extension that makes useful things appear out of the void (JS & TS) 🔮
TypeScript
33
star
5

nicoespeon.github.io

Personal github hosted blog.
JavaScript
27
star
6

sass-graph-viz

Draw a visual graph of Sass dependencies
TypeScript
25
star
7

jest-extended-snapshot

Additional Jest matchers for snapshot testing.
TypeScript
18
star
8

design-patterns

Implementation of Design Patterns in JS
JavaScript
17
star
9

talk-how-to-change-untested-code

Slides of my talk "I need to change this code, but it has no test! 🙀"
JavaScript
5
star
10

kata-gilded-rose-js

The Gilded Rose refactoring kata, in JavaScript. I use this during trainings.
JavaScript
5
star
11

talk-build-your-first-vscode-extension

Code of my workshop "Let's craft automated refactorings ourselves!"
5
star
12

growing-oo-software

TypeScript implementation of the use-case depicted in "Growing Object-Oriented Software, Guided by Tests"
TypeScript
4
star
13

talk-secrets-hexagonal-architecture

Slides of my talk "The Secrets of Hexagonal Architecture"
PHP
3
star
14

manawa

Helps you stay focus using the Pomodoro technique
TypeScript
2
star
15

refactoringjavascript.dev

Host of my Refactoring JavaScript course
JavaScript
2
star
16

learnsomevscode.com

Learn VS Code tips & tricks. Be more productive. Ship faster.
JavaScript
2
star
17

starter-kit-phoenix-elm

A starter kit for projects with Phoenix + Elm
Elixir
2
star
18

understandlegacycode.com

Change Messy Software Without Breaking It
JavaScript
2
star
19

ts-tidy

Find and clean dead TS code in a single command 🧼
JavaScript
1
star
20

my-spotify-groomer

💤 [Not maintained] Clean my Spotify playlists from tracks I don't like anymore.
JavaScript
1
star
21

dotfiles

Collection of personal dotfiles
Shell
1
star
22

reports

Misc. personal reports from meetups and events. Either in English or French.
1
star
23

talk-drawing-git-graphs

Talk "Drawing Git Graphs in the Browser"
JavaScript
1
star
24

jest-html-loader

Integration of html-loader package with Jest 28+
JavaScript
1
star