JS Refactor has two key components: automated refactorings and code snippets.
First release of JS Refactorings for Atom
JS Refactor supports the following refactorings (explanations below):
Select the code you wish to refactor, right click to open the context menu and select the refactoring from the menu.
Convert To Member Function Converts a named function to a member function for an object prototype definition.
Convert To Named Function Converts selected anonymous function assignment or member function declaration and converts it into a named function declaration. Convert to named function only searches the first line of your selection and will only convert one function at a time.
Export Function creates new export declaration for selected function or function name
Extract Variable Creates new assigned variable declaration and extracts repeated values.
Shift Parameters Left Shifts all selected parameters to the left
Shift Parameters Right Shifts all selected parameters to the right
Wrap In Condition Wraps selected code in an if statement, adding indentation as necessary
Wrap In Executed Function is an extra step on top of wrap in function. Instead of simply wrapping your selected code in a new function declaration, JS Refactor encloses your code in a named function and immediately executes the new function on the next line. This makes the "extract method/function" refactoring trivial to implement since the only work needed is to move the new function to an appropriate location in the code.
Wrap in function takes your selected code, at line-level precision, and wraps all of the lines in a named function.
Wrap in IIFE wraps selected code in an immediately invoked function expression (IIFE).
JS Refactor supports several common code snippets:
Type the abbreviation, such as fn, in your code and hit enter. When the snippet is executed, the appropriate code will be inserted into your document. Any snippets which require extra information like names or arguments will have named tab-stops where you can fill in the information unique to your program.
anon Inserts a tab-stopped anonymous function snippet into your code
export Adds a module.exports single var assignment in your module
exportObj Adds a module.exports assignment with an object literal
fn Inserts a tab-stopped named function snippet into your code
lfn Inserts a tab-stopped lambda function snippet into your code
iife Inserts a new, tab-stopped IIFE into your code
mfn Inserts a new color-delimited member function to your prototype -- Protip be inside a prototype object when using this.
require Inserts a new require statement in your module
strict Inserts 'use strict' into your code
JS Refactorings is open to pull requests for everything from code to documentation. As with any project, there are certain needs which must be addressed. JS Refactorings is, at its core, still in development. In its current state, JS Refactorings is fully tested and behaviors are vice-tested into place. Going forward, code will be cleaned and, itself, refactored, so a style guide is going to be relatively fluid.
Nevertheless, following are the required elements of a good pull request:
Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.