@unix/eslint 1.1.1 → 1.1.2
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.
|
@@ -86,6 +86,15 @@ const reportPadding = (
|
|
|
86
86
|
|
|
87
87
|
const isReturnStatement = node => node.type === 'ReturnStatement'
|
|
88
88
|
|
|
89
|
+
const isCompactReturnIfStatement = node =>
|
|
90
|
+
node.type === 'IfStatement' &&
|
|
91
|
+
!node.alternate &&
|
|
92
|
+
isReturnStatement(node.consequent) &&
|
|
93
|
+
node.loc.start.line === node.consequent.loc.start.line
|
|
94
|
+
|
|
95
|
+
const isReturnLikeStatement = node =>
|
|
96
|
+
isReturnStatement(node) || isCompactReturnIfStatement(node)
|
|
97
|
+
|
|
89
98
|
const lineCountFor = node => node.loc.end.line - node.loc.start.line + 1
|
|
90
99
|
|
|
91
100
|
const hasBlockBody = node => {
|
|
@@ -107,14 +116,14 @@ const isLongBlockStatement = node =>
|
|
|
107
116
|
|
|
108
117
|
const messageIdForStatementGap = (previousStatement, nextStatement) => {
|
|
109
118
|
if (isReturnStatement(previousStatement)) return 'unexpectedBlankLineAfterReturn'
|
|
110
|
-
if (
|
|
119
|
+
if (isReturnLikeStatement(nextStatement)) return 'tooManyBlankLinesBeforeReturn'
|
|
111
120
|
|
|
112
121
|
return 'unexpectedBlankLine'
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
const maxBlankLinesForStatementGap = (previousStatement, nextStatement) => {
|
|
116
125
|
if (isReturnStatement(previousStatement)) return 0
|
|
117
|
-
if (
|
|
126
|
+
if (isReturnLikeStatement(nextStatement)) return 1
|
|
118
127
|
if (isLongBlockStatement(previousStatement)) return 1
|
|
119
128
|
if (isLongBlockStatement(nextStatement)) return 1
|
|
120
129
|
|