canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS, CSS and JSON.
33 lines (31 loc) • 961 B
JavaScript
;
var _ = require('lodash');
module.exports = {
/**
* Returns the lodash object settings, with default values if missing
* @param context
* @returns {LodashSettings}
*/
getSettings: function (context) {
return _.chain(context)
.get(['settings', 'lodash'])
.defaults({
pragma: '_',
version: 4
})
.value();
},
/**
* Gets whether the ecmaFeature specified is on for the context
* @param context
* @param {string} featureName
*/
isEcmaFeatureOn: function (context, featureName) {
return _.get(context, ['ecmaFeatures', featureName]) || (_.get(context, ['parserOptions', 'ecmaVersion'], 0) > 5);
}
};
/**
@typedef {Object} LodashSettings
@property {String} pragma - The symbol that signifies Lodash (default is '_').
@property {Number} version - The major version number (default is 4).
*/