@@ -39,6 +39,8 @@ module.exports = {
39
39
40
40
const openingElementEndLine = node . loc . end . line ;
41
41
42
+ // TODO: Just check if my parent opening tag is on the same line as me.
43
+
42
44
// Children
43
45
if ( node . parent . children . length ) {
44
46
const childrenOnLine = [ ] ;
@@ -55,11 +57,11 @@ module.exports = {
55
57
return ;
56
58
}
57
59
58
- childrenOnLine . forEach ( elementInLine => {
60
+ childrenOnLine . forEach ( childOnLine => {
59
61
context . report ( {
60
- node : elementInLine ,
61
- message : `Opening tag for Element \`${ elementInLine . openingElement . name . name } \` must be placed on a new line` ,
62
- fix : generateFixFunction ( elementInLine )
62
+ node : childOnLine ,
63
+ message : `Opening tag for Element \`${ childOnLine . openingElement . name . name } \` must be placed on a new line` ,
64
+ fix : generateFixFunction ( childOnLine )
63
65
} ) ;
64
66
} ) ;
65
67
}
@@ -85,26 +87,22 @@ module.exports = {
85
87
return ;
86
88
}
87
89
88
- const childrenOnLine = [ ] ;
89
90
const closingElementStartLine = node . loc . end . line ;
90
91
91
- node . parent . children . forEach ( childNode => {
92
- const reportableLines = [ childNode . openingElement , childNode . closingElement ] . reduce ( ( lines , el ) => {
92
+ const anyChildrenOnLine = node . parent . children . some ( child => {
93
+ const reportableLines = [ child . openingElement , child . closingElement ] . reduce ( ( lines , el ) => {
93
94
if ( ! el ) {
94
95
return lines ;
95
96
}
96
97
97
98
return lines . concat ( [ el . loc . start . line , el . loc . end . line ] ) ;
98
99
} , [ ] ) ;
99
100
100
- if ( reportableLines . indexOf ( closingElementStartLine ) === - 1 ) {
101
- return ;
102
- }
103
101
104
- childrenOnLine . push ( childNode ) ;
102
+ return reportableLines . indexOf ( closingElementStartLine ) !== - 1 ;
105
103
} ) ;
106
104
107
- if ( ! childrenOnLine . length ) {
105
+ if ( ! anyChildrenOnLine ) {
108
106
return ;
109
107
}
110
108
0 commit comments