UNPKG

627 BJavaScriptView Raw
1// detect if object with multiple properties is written in single line
2// For example this is confusing `margins: {top: 20, bottom: 20, left: 20, right: 90}`
3/* global module */
4module.exports = function (context) {
5 'use strict';
6
7 return {
8 ObjectExpression: function (node) {
9 var nProperties = node.properties.length;
10 if (nProperties > 1) {
11 var nLines = node.loc.end.line - node.loc.start.line;
12 if (nLines < nProperties) {
13 context.report(node, 'too many object properties (' + nProperties +
14 ') written in ' + (nLines + 1) + ' line(s)');
15 }
16 }
17 }
18 };
19};