2016-12-23 21:38:10 +03:00
|
|
|
var defaults = {
|
2017-01-10 07:22:58 +03:00
|
|
|
// Number of spaces the pretty-printer should use per tab
|
2017-01-05 01:23:07 +03:00
|
|
|
tabWidth: 2,
|
2017-01-10 07:22:58 +03:00
|
|
|
// Fit code within this line limit
|
2017-01-05 01:23:07 +03:00
|
|
|
printWidth: 80,
|
2017-01-05 18:01:43 +03:00
|
|
|
// If true, will use single instead of double quotes
|
|
|
|
singleQuote: false,
|
2017-01-10 07:22:58 +03:00
|
|
|
// Controls the printing of trailing commas wherever possible
|
2016-12-23 21:38:10 +03:00
|
|
|
trailingComma: false,
|
2017-01-05 01:23:07 +03:00
|
|
|
// Controls the printing of spaces inside array and objects
|
|
|
|
bracketSpacing: true
|
2017-01-05 04:45:28 +03:00
|
|
|
};
|
2016-12-23 21:38:10 +03:00
|
|
|
|
|
|
|
// Copy options and fill in default values.
|
|
|
|
exports.normalize = function(options) {
|
2017-01-05 04:45:28 +03:00
|
|
|
const normalized = Object.assign({}, options);
|
|
|
|
Object.keys(defaults).forEach(k => {
|
2017-01-13 23:03:53 +03:00
|
|
|
if (normalized[k] == null) {
|
2017-01-05 04:45:28 +03:00
|
|
|
normalized[k] = defaults[k];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return normalized;
|
2016-12-23 21:38:10 +03:00
|
|
|
};
|