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 | var assert = require('assert');
|
28 |
|
29 | module.exports = function() {};
|
30 |
|
31 | module.exports.prototype = {
|
32 | configure: function(options) {
|
33 | assert(
|
34 | options === true,
|
35 | this.getOptionName() + ' option requires a true value or should be removed'
|
36 | );
|
37 | },
|
38 |
|
39 | getOptionName: function() {
|
40 | return 'requireMultiLineTernary';
|
41 | },
|
42 |
|
43 | check: function(file, errors) {
|
44 | file.iterateNodesByType('ConditionalExpression', function(node) {
|
45 |
|
46 | errors.assert.differentLine({
|
47 | token: node.test,
|
48 | nextToken: node.consequent,
|
49 | message: 'Missing new line after test'
|
50 | });
|
51 |
|
52 | errors.assert.differentLine({
|
53 | token: node.consequent,
|
54 | nextToken: node.alternate,
|
55 | message: 'Missing new line after consequent'
|
56 | });
|
57 |
|
58 | });
|
59 | }
|
60 |
|
61 | };
|