Releases: nicoespeon/abracadabra
Releases · nicoespeon/abracadabra
Join the Herd 🐾
Fixed
- Extract Type will now put the cursor at the proper position to rename the extracted type when leading comments are present. Thanks @fabien0102 for catching this!
- Extracting multiple variables on the same line will correctly position the cursor to trigger a rename. That was an annoying edge-case, not anymore!
Changed
- @chrstnbrn improved error messages for when the AST can't be built. That should help you understand what went wrong when things don't work 👍
- Convert to Arrow Function will only prompt a quick fix if your cursor is on the function declaration, not its body. This will reduce the noise when working with large functions.
- Extract Variable will re-use existing destructured declaration. So for this code:
function test(obj) {
return obj.x + obj.y * obj.x + obj.y;
}
After extracting x
and y
(and choosing to "destructure" it) the end result will now be:
function test(obj) {
const { x, y } = obj;
return x + y * x + y;
}
- @ZakMiller made "Convert for to forEach" works with for..of loops too. Nice!
5.0.1
Fixed
- Attempting to extract a variable was hijacked with the new Extract Type refactoring. This is fixed so we can now execute both again!
Typing In the Name 🤖
Changed
- (Breaking) Extract Generic Type can't be triggered with
Ctrl + Alt + V
anymore. We assigned this shortcut to the new Extract Type refactoring instead (more intuitive). This refactoring is now available through a Quick Fix though 💡
Added
- [New Refactoring] Extract Type! It works exactly like Extract Variable, but for types. Even more convenient: the shortcut is the same (
Ctrl + Alt + V
/⌥ ⌘ V
on MacOS). If you're on a variable, it will extract the variable. If you're on a type, it will extract the type 😉 - [New Refactoring] Split Multiple Declarations, to create distinct variable declarations from a single one. Thanks to @iulspop for this one!
Fixed
- Split Declaration and Initialization would duplicate type annotations in TypeScript. @iulspop fixed that 🔥
4.13.1
No user-facing change. Configuration was fixed so the extension can be deployed again.
Moves Like Function 🎬
Added
- [New Refactoring] Move to existing file. Long-time awaited feature and a nice complement to VS Code's native "Move to new file". It only works for function declarations (for now).
Fixed
- Extract Variable resulted in broken code when executed on the condition of an
else
statement. The variable declaration was inserted in the middle of the if statement: not good. This is solved now! - Convert to Arrow Function would not work if some imported types were used before the function declaration. That was weird, but it has been fixed 😄
4.12.1
Fixed
- Extract Variable now find the correct scope when the only common ancestor is the Program. So extracting these
"hello"
will now generate the correct code:
if (isValid) {
console.log("hello");
} else {
console.log("hello");
}
// 🚫 Used to generate:
if (isValid) {
const hello = "hello";
console.log(hello);
} else {
console.log(hello);
}
// ✅ Will now generate:
const hello = "hello";
if (isValid) {
console.log(hello);
} else {
console.log(hello);
}
- Extract Variable won't suggest a name that would shadow a binding in scope. That should prevent breaking code when the string literal you want to extract has the same value than an existing variable.
function greeting(extracted, hello) {
console.log("hello", extracted, hello);
}
// 🚫 Used to generate:
function greeting(extracted, hello) {
const hello = "hello";
console.log(hello, extracted, hello);
}
// ✅ Will now generate:
function greeting(extracted, hello) {
const extracted1 = "hello";
console.log(extracted1, extracted, hello);
}
It also means you can extract multiple variables
- Prevents "Convert to Arrow Function" to be executed on code if function is referenced above. This is because generated code would be invalid since the function declaration wouldn't be hoisted anymore.
Hide and Seek 🙈
Added
- You can now hide refactorings from Quick Fix suggestions!
There are over 30 refactorings supported by the extension now, and you may not be using all of them. If you want to reduce the noise, you can now disable the suggestions you don't use from VS Code settings.
Changed
- "Convert to Arrow Function" used to convert the top-most function declaration, which was unexpected when you have nested ones! It now converts function that's the closest to the cursor position.
The Vue has Changed 👩
Added
- Rename Symbol now works on
.vue
files. The UX is slightly different as we didn't managed to get the input pop next to the renamed symbol, but it's very similar to what you can do in any other language.
This means other refactorings like "Extract Variable" are now smoother in .vue
files, since they rely on "Rename Symbol" to reduce the amount of keystrokes you need to do!
It works when you press F2
like anywhere else.
Block to be Alive 🐶
Changed
- Negate Expression quick fix stops saying "(use null instead)" when it can't compute the negated operator
- Inline Variable now works on computed properties, so this would work:
// Inline `name` will now work…
const name = "John";
console.log({ [name]: "Doe" });
// … and generate this code:
console.log({ ["John"]: "Doe" });
Fixed
- Extract Variable now works fine when executed inside block statements and it matches multiple occurrences. It means that this code:
function venueBtnName() {
if (window.location.href.includes("raw")) {
document.getElementById("venueExampleBtn").innerHTML = "Venue Examples";
} else {
document.getElementById("venueExampleBtn").innerHTML =
"Venue Group Details";
}
}
Will produce this code, as expected:
function venueBtnName() {
const extracted = document.getElementById("venueExampleBtn");
if (window.location.href.includes("raw")) {
extracted.innerHTML = "Venue Examples";
} else {
extracted.innerHTML = "Venue Group Details";
}
}
4.9.3
Fixed
- Flip ternary now works correctly with
instanceof
andin
operators - Extract Variable stop asking for destructuring strategy when member expression is computed