1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | var assert = require('assert');
|
33 |
|
34 | module.exports = function() {};
|
35 |
|
36 | module.exports.prototype = {
|
37 | configure: function(options) {
|
38 | assert(
|
39 | options === true,
|
40 | this.getOptionName() + ' option requires a true value or should be removed'
|
41 | );
|
42 | },
|
43 |
|
44 | getOptionName: function() {
|
45 | return 'disallowObjectKeysOnNewLine';
|
46 | },
|
47 |
|
48 | check: function(file, errors) {
|
49 | file.iterateNodesByType('ObjectExpression', function(node) {
|
50 | var properties = node.properties;
|
51 | for (var i = 1; i < properties.length; i++) {
|
52 | var propertyNode = properties[i];
|
53 |
|
54 | errors.assert.sameLine({
|
55 | token: propertyNode.getPreviousCodeToken(),
|
56 | nextToken: propertyNode.getFirstToken(),
|
57 | message: 'Object keys should be on the same line'
|
58 | });
|
59 | }
|
60 | });
|
61 | }
|
62 | };
|