require-sort
v0.3.0
Published
A utility for sorting require() statements.
Downloads
8
Readme
require-sort
A utility for sorting require() statements.
Installation
$ npm install require-sort
Functionality
- Sorts based on required name, not variable name
- Sorts into groups based on directory location
- Sorts all sections of require statements
var alpha = require("alpha"); // external group
var xalpha = require("xalpha"); // ...
var beta = require("beta/beta"); // path group
var xbeta = require("xbeta/xbeta"); // ...
var gamma = require("/gamma"); // absolute group
var xgamma = require("/xgamma"); // ...
var delta = require("./delta"); // relative group
var xdelta = require("./xdelta"); // ...
var epsilon = require("../epsilon"); // parent group
var xepsilon = require("../xepsilon"); // ...
Usage
var sorter = require("require-sort");
// file content in inputString
var sortedString = sorter.sortString(inputString);
// custom options object
var sortedString = sorter.sortString(inputString, options);
Options
var options = {
emptyLines: false // separate require statement groups with empty lines
};