Skip to content

Commit 7a7429d

Browse files
committed
Fix failing tests
1 parent 7be3ee5 commit 7a7429d

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

lib/rules/jsx-closing-tag-location.js

+34-21
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ const report = require('../util/report');
1818
// ------------------------------------------------------------------------------
1919

2020
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.',
2223
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',
2426
};
2527

2628
const defaultOption = 'tag-aligned';
@@ -41,22 +43,24 @@ module.exports = {
4143
},
4244
fixable: 'whitespace',
4345
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+
},
5458
},
59+
additionalProperties: false,
5560
},
56-
additionalProperties: false,
57-
},
58-
],
59-
}],
61+
],
62+
},
63+
],
6064
},
6165

6266
create(context) {
@@ -72,8 +76,8 @@ module.exports = {
7276
}
7377

7478
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;
7781
}
7882

7983
function handleClosingElement(node) {
@@ -95,11 +99,17 @@ module.exports = {
9599
return;
96100
}
97101

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+
) {
99106
return;
100107
}
101108

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+
) {
103113
return;
104114
}
105115

@@ -111,7 +121,10 @@ module.exports = {
111121
node,
112122
loc: node.loc,
113123
fix(fixer) {
114-
const indent = repeat(' ', getIndentation(openingStartOfLine, opening));
124+
const indent = repeat(
125+
' ',
126+
getIndentation(openingStartOfLine, opening)
127+
);
115128

116129
if (astUtil.isNodeFirstInLine(context, node)) {
117130
return fixer.replaceTextRange(

0 commit comments

Comments
 (0)