Releases: nicoespeon/abracadabra
Releases · nicoespeon/abracadabra
I'm a Believer 🦅
Changed
- Extracting an object property value would not detect similar values in the scope. Now it does! Thanks @SelrahcD for reporting this one! (#1269)
const userConfig = {
apiBaseUrl: "https://api.example.com",
// 👇 Extracting this `30000` now detects all 4 occurrences!
apiTimeout: 30000,
dbTimeout: 30000,
cacheTimeout: 30000
};
const apiTimeout = 30000;9.9.1
Fixed
- When you type
${}in a string literal, Abracadabra can automatically convert it into a template literal. But the code is technically invalid until you type the variable name. Thus, Abracadabra was reporting an error message every time you do so. Since this is intended, we silenced that. No more noise!
For the First Time as a Param 🧊
Added
- [New Refactoring] "Extract Parameter" which converts a variable declaration into a function parameter. Thank you @pinage404 for finishing this one!
9.8.1
Fixed
- Abracadabra shortcuts would attempt to trigger a refactoring, regardless of the language of the file. These are now restricted to JS/TS files, just like Command Palette and Quick Fixes suggestions. Thanks @PetrusAsikainen for reporting this one!
I’ve Got a Log 🍳
Added
- Abracadabra error logs are now sent to the VS Code "Output" tab, in a dedicated channel. It also contains more details, so it's easier to debug issues. Thanks @ackvf for raising this one!
If You Believe in Ifs 🌠
Added
- [New Refactoring] "Convert Guard to If" that turns one-liners like
condition && doThis()into a proper if-statement likeif (condition) { doThis(); }. Thanks to @tomasossa for this one 🎉
Fixed
- Handles more scenario where "Extract Function" would run on partially selected statements. It used to expand to the closest parent statement, which might have included siblings you didn't mean to extract. Now it only expands to the closest list of statements that overlap with the selection—that's better!
9.6.1
Fixed
- "Extract Function" now correctly expands the selection when multiple statements of a block statement are selected. It used to include the wrapping braces, preventing the refactoring.
I Just Can’t Wait to Extract 🦁
Added
- [New Refactoring] "Extract Function". It's merely a proxy to VS Code "Extract Function" refactoring. But it assigns a keybinding (
Ctrl + Alt + M/⌥ ⌘ Mon MacOS) for discoverability. It also transforms the code right away if there is a single possible extraction. Finally, it will expand the selection to the closest statement you can extract. So you don't have to precisely select the statement you intend to extract.
- [New Refactoring] "Move Last Statement out of If/Else". Sometimes you have duplicated code at the end of an if/else statement. This refactoring will pull it out and simplify the code accordingly.
Whistle While You Work 🛠️
Fixed
- Abracadabra was messing up the shebang line when executing refactorings, unless you were using
#!/usr/bin/env node. This is now fixed for any shebang line. Also, it won't mess up formatting if your code happens to have a shebang-looking line elsewhere (e.g., in a comment). Thanks @datenreisender for catching that 👍
Changed
- "Extract Variable" now combines destructured property with existing ones from Member Expressions, not just Identifiers. To put it simply, if you have
const { x } = some.object;and you extractsome.object.y, it will combine them to becomeconst { x, y } = some.object; - Highlights are refreshed after a refactoring has been executed. So if you highlight some Identifier and then refactor the code (e.g. Extract Variable), the resulting code will be highlighted accordingly. Very convenient when performing Peel and Slice refactorings.
- Toggling braces in JSX components was adding unnecessary braces, sometimes. This is not the case anymore.
9.4.9
Fixed
- "Inline Variable" was not working for references that were computed, such as
aList[varToInline]. These are resolved properly and correctly replaced now.
Changed
- "Move Statements" refactorings now preserve the original style better. They used to update the AST and regenerate the code from it, but that was messing up with formatting quite often. Now we use the AST to determine the code to swap, but read the exact code from the editor so that should preserve the original style!




