2017-01-20 00:45:36 +03:00
|
|
|
"use strict";
|
|
|
|
|
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
|
2017-01-20 01:35:12 +03:00
|
|
|
bracketSpacing: true,
|
|
|
|
// Which parser to use. Valid options are 'flow' and 'babylon'
|
|
|
|
parser: 'babylon'
|
2017-01-05 04:45:28 +03:00
|
|
|
};
|
2016-12-23 21:38:10 +03:00
|
|
|
|
|
|
|
// Copy options and fill in default values.
|
2017-01-20 00:45:36 +03:00
|
|
|
function normalize(options) {
|
2017-01-19 23:43:10 +03:00
|
|
|
const normalized = Object.assign({}, options || {});
|
2017-01-20 01:35:12 +03:00
|
|
|
|
|
|
|
// For backward compatibility. Deprecated in 0.0.10
|
|
|
|
if ('useFlowParser' in normalized) {
|
|
|
|
normalized.parser = normalized.useFlowParser ? 'flow' : 'babylon';
|
|
|
|
delete normalized.useFlowParser;
|
|
|
|
}
|
|
|
|
|
2017-01-05 04:45:28 +03:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
});
|
2017-01-20 01:35:12 +03:00
|
|
|
|
2017-01-05 04:45:28 +03:00
|
|
|
return normalized;
|
2016-12-23 21:38:10 +03:00
|
|
|
};
|
2017-01-20 00:45:36 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
normalize
|
|
|
|
};
|