canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS, CSS and JSON.
27 lines (18 loc) • 686 B
JavaScript
/* global module */
;
module.exports = function (context) {
var checkObjectExpression = function(node) {
var numberOfProperties = node.properties.length;
var objHasMultipleProperties = (numberOfProperties > 1);
var propertyOnSameLineAsOpeningBrace;
if (objHasMultipleProperties) {
propertyOnSameLineAsOpeningBrace = (node.properties[0].loc.start.line === node.loc.start.line);
if (propertyOnSameLineAsOpeningBrace) {
context.report(node, 'object property on same line as opening brace');
}
}
};
return {
ObjectExpression: checkObjectExpression
};
};