@plumeria/eslint-plugin 9.0.1 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,6 +30,7 @@ exports.formatProperties = {
|
|
|
30
30
|
const baseIndent = parentLine.match(/^(\s*)/)[1];
|
|
31
31
|
const innerIndent = baseIndent + ' ';
|
|
32
32
|
const countNewlines = (text) => (text.match(/\n/g) ?? []).length;
|
|
33
|
+
const isWhitespaceOnly = (text) => /^\s*$/.test(text);
|
|
33
34
|
const fullText = sourceCode.getText();
|
|
34
35
|
const openBrace = sourceCode.getFirstToken(node);
|
|
35
36
|
const closeBrace = sourceCode.getLastToken(node);
|
|
@@ -48,7 +49,7 @@ exports.formatProperties = {
|
|
|
48
49
|
const newlines = countNewlines(between);
|
|
49
50
|
if (newlines === 0)
|
|
50
51
|
hasError = true;
|
|
51
|
-
if (newlines > 1)
|
|
52
|
+
if (newlines > 1 && isWhitespaceOnly(between))
|
|
52
53
|
hasBlankLines = true;
|
|
53
54
|
}
|
|
54
55
|
const lastProp = properties[properties.length - 1];
|
|
@@ -68,7 +69,10 @@ exports.formatProperties = {
|
|
|
68
69
|
const next = properties[i + 1];
|
|
69
70
|
const comma = sourceCode.getTokenAfter(current);
|
|
70
71
|
if (comma.value === ',') {
|
|
71
|
-
|
|
72
|
+
const betweenText = fullText.slice(comma.range[1], next.range[0]);
|
|
73
|
+
if (isWhitespaceOnly(betweenText)) {
|
|
74
|
+
fixes.push(fixer.replaceTextRange([comma.range[1], next.range[0]], `\n${innerIndent}`));
|
|
75
|
+
}
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
const lastComma = sourceCode.getTokenAfter(lastProp);
|
|
@@ -95,7 +99,7 @@ exports.formatProperties = {
|
|
|
95
99
|
const comma = sourceCode.getTokenAfter(current);
|
|
96
100
|
const sliceStart = comma.range[1];
|
|
97
101
|
const between = fullText.slice(sliceStart, next.range[0]);
|
|
98
|
-
if (countNewlines(between) > 1) {
|
|
102
|
+
if (countNewlines(between) > 1 && isWhitespaceOnly(between)) {
|
|
99
103
|
const blankLineNumber = current.loc.end.line + 1;
|
|
100
104
|
context.report({
|
|
101
105
|
loc: {
|