@@ -18,9 +18,11 @@ const report = require('../util/report');
18
18
// ------------------------------------------------------------------------------
19
19
20
20
const messages = {
21
- onOwnLine : 'Closing tag of a multiline JSX expression must be on its own line.' ,
21
+ onOwnLine :
22
+ 'Closing tag of a multiline JSX expression must be on its own line.' ,
22
23
matchIndent : 'Expected closing tag to match indentation of opening.' ,
23
- alignWithOpening : 'Expected closing tag to be aligned with the line containing the opening tag' ,
24
+ alignWithOpening :
25
+ 'Expected closing tag to be aligned with the line containing the opening tag' ,
24
26
} ;
25
27
26
28
const defaultOption = 'tag-aligned' ;
@@ -41,22 +43,24 @@ module.exports = {
41
43
} ,
42
44
fixable : 'whitespace' ,
43
45
messages,
44
- schema : [ {
45
- anyOf : [
46
- {
47
- enum : [ 'tag-aligned' , 'line-aligned' ] ,
48
- } ,
49
- {
50
- type : 'object' ,
51
- properties : {
52
- location : {
53
- enum : [ 'tag-aligned' , 'line-aligned' ] ,
46
+ schema : [
47
+ {
48
+ anyOf : [
49
+ {
50
+ enum : [ 'tag-aligned' , 'line-aligned' ] ,
51
+ } ,
52
+ {
53
+ type : 'object' ,
54
+ properties : {
55
+ location : {
56
+ enum : [ 'tag-aligned' , 'line-aligned' ] ,
57
+ } ,
54
58
} ,
59
+ additionalProperties : false ,
55
60
} ,
56
- additionalProperties : false ,
57
- } ,
58
- ] ,
59
- } ] ,
61
+ ] ,
62
+ } ,
63
+ ] ,
60
64
} ,
61
65
62
66
create ( context ) {
@@ -72,8 +76,8 @@ module.exports = {
72
76
}
73
77
74
78
function getIndentation ( openingStartOfLine , opening ) {
75
- if ( option === 'line-aligned' ) return openingStartOfLine . column + 1 ;
76
- if ( option === 'tag-aligned' ) return opening . loc . start . column + 1 ;
79
+ if ( option === 'line-aligned' ) return openingStartOfLine . column ;
80
+ if ( option === 'tag-aligned' ) return opening . loc . start . column ;
77
81
}
78
82
79
83
function handleClosingElement ( node ) {
@@ -95,11 +99,17 @@ module.exports = {
95
99
return ;
96
100
}
97
101
98
- if ( opening . loc . start . column === node . loc . start . column && option === 'tag-aligned' ) {
102
+ if (
103
+ opening . loc . start . column === node . loc . start . column &&
104
+ option === 'tag-aligned'
105
+ ) {
99
106
return ;
100
107
}
101
108
102
- if ( openingStartOfLine . column === node . loc . start . column && option === 'line-aligned' ) {
109
+ if (
110
+ openingStartOfLine . column === node . loc . start . column &&
111
+ option === 'line-aligned'
112
+ ) {
103
113
return ;
104
114
}
105
115
@@ -111,7 +121,10 @@ module.exports = {
111
121
node,
112
122
loc : node . loc ,
113
123
fix ( fixer ) {
114
- const indent = repeat ( ' ' , getIndentation ( openingStartOfLine , opening ) ) ;
124
+ const indent = repeat (
125
+ ' ' ,
126
+ getIndentation ( openingStartOfLine , opening )
127
+ ) ;
115
128
116
129
if ( astUtil . isNodeFirstInLine ( context , node ) ) {
117
130
return fixer . replaceTextRange (
0 commit comments