@saasmakers/eslint 1.0.13 → 1.0.17
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.
- package/dist/index.cjs +43 -4
- package/dist/index.mjs +43 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -139,6 +139,30 @@ const rule$b = {
|
|
|
139
139
|
function collapseBlankLine(text) {
|
|
140
140
|
return text.replace(/\n[^\S\n]*\n[^\S\n]*/, "\n");
|
|
141
141
|
}
|
|
142
|
+
function expressionStartsWithIdentifier(node, identifier) {
|
|
143
|
+
if (node.type === index$1.distExports.AST_NODE_TYPES.Identifier && node.name === identifier) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
if (node.type === index$1.distExports.AST_NODE_TYPES.CallExpression) {
|
|
147
|
+
const { callee } = node;
|
|
148
|
+
if (callee.type === index$1.distExports.AST_NODE_TYPES.Identifier && callee.name === identifier) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (callee.type === index$1.distExports.AST_NODE_TYPES.MemberExpression) {
|
|
152
|
+
return expressionStartsWithIdentifier(callee.object, identifier);
|
|
153
|
+
}
|
|
154
|
+
if (callee.type === index$1.distExports.AST_NODE_TYPES.ChainExpression) {
|
|
155
|
+
return expressionStartsWithIdentifier(callee.expression, identifier);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (node.type === index$1.distExports.AST_NODE_TYPES.MemberExpression) {
|
|
159
|
+
return expressionStartsWithIdentifier(node.object, identifier);
|
|
160
|
+
}
|
|
161
|
+
if (node.type === index$1.distExports.AST_NODE_TYPES.ChainExpression) {
|
|
162
|
+
return expressionStartsWithIdentifier(node.expression, identifier);
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
142
166
|
function expressionUsesThis(expression) {
|
|
143
167
|
if (expression.type === index$1.distExports.AST_NODE_TYPES.AssignmentExpression) {
|
|
144
168
|
return isThisReceiver(expression.left);
|
|
@@ -146,9 +170,6 @@ function expressionUsesThis(expression) {
|
|
|
146
170
|
if (expression.type === index$1.distExports.AST_NODE_TYPES.CallExpression) {
|
|
147
171
|
return isThisReceiver(expression.callee);
|
|
148
172
|
}
|
|
149
|
-
if (expression.type === index$1.distExports.AST_NODE_TYPES.OptionalCallExpression) {
|
|
150
|
-
return isThisReceiver(expression.callee);
|
|
151
|
-
}
|
|
152
173
|
if (expression.type === index$1.distExports.AST_NODE_TYPES.UpdateExpression) {
|
|
153
174
|
return isThisReceiver(expression.argument);
|
|
154
175
|
}
|
|
@@ -212,6 +233,15 @@ function getStatementKind(node) {
|
|
|
212
233
|
}
|
|
213
234
|
return isSingleLine(node) ? "singleline-assignment" : "multiline-assignment";
|
|
214
235
|
}
|
|
236
|
+
if (isExpectExpression(node.expression)) {
|
|
237
|
+
return isSingleLine(node) ? "singleline-expect" : "multiline-expect";
|
|
238
|
+
}
|
|
239
|
+
if (isAssertExpression(node.expression)) {
|
|
240
|
+
return isSingleLine(node) ? "singleline-assert" : "multiline-assert";
|
|
241
|
+
}
|
|
242
|
+
if (isConsoleExpression(node.expression)) {
|
|
243
|
+
return isSingleLine(node) ? "singleline-console" : "multiline-console";
|
|
244
|
+
}
|
|
215
245
|
if (expressionUsesThis(node.expression)) {
|
|
216
246
|
return isSingleLine(node) ? "singleline-this" : "multiline-this";
|
|
217
247
|
}
|
|
@@ -235,12 +265,21 @@ function hasLineCommentBetween(prevNode, nextNode, sourceCode) {
|
|
|
235
265
|
return comment.range[0] >= prevNode.range[1] && comment.range[1] <= nextNode.range[0];
|
|
236
266
|
});
|
|
237
267
|
}
|
|
268
|
+
function isAssertExpression(expression) {
|
|
269
|
+
return expressionStartsWithIdentifier(expression, "assert");
|
|
270
|
+
}
|
|
271
|
+
function isConsoleExpression(expression) {
|
|
272
|
+
return expressionStartsWithIdentifier(expression, "console");
|
|
273
|
+
}
|
|
238
274
|
function isDirectivePrologue(node) {
|
|
239
275
|
if (node.expression.type !== index$1.distExports.AST_NODE_TYPES.Literal) {
|
|
240
276
|
return false;
|
|
241
277
|
}
|
|
242
278
|
return typeof node.expression.value === "string";
|
|
243
279
|
}
|
|
280
|
+
function isExpectExpression(expression) {
|
|
281
|
+
return expressionStartsWithIdentifier(expression, "expect");
|
|
282
|
+
}
|
|
244
283
|
function isOwnLineComment(comment, sourceCode) {
|
|
245
284
|
if (comment.type !== "Line") {
|
|
246
285
|
return false;
|
|
@@ -258,7 +297,7 @@ function isThisReceiver(node) {
|
|
|
258
297
|
if (node.type === index$1.distExports.AST_NODE_TYPES.ThisExpression) {
|
|
259
298
|
return true;
|
|
260
299
|
}
|
|
261
|
-
if (node.type === index$1.distExports.AST_NODE_TYPES.MemberExpression
|
|
300
|
+
if (node.type === index$1.distExports.AST_NODE_TYPES.MemberExpression) {
|
|
262
301
|
return isThisReceiver(node.object);
|
|
263
302
|
}
|
|
264
303
|
if (node.type === index$1.distExports.AST_NODE_TYPES.ChainExpression) {
|
package/dist/index.mjs
CHANGED
|
@@ -137,6 +137,30 @@ const rule$b = {
|
|
|
137
137
|
function collapseBlankLine(text) {
|
|
138
138
|
return text.replace(/\n[^\S\n]*\n[^\S\n]*/, "\n");
|
|
139
139
|
}
|
|
140
|
+
function expressionStartsWithIdentifier(node, identifier) {
|
|
141
|
+
if (node.type === distExports.AST_NODE_TYPES.Identifier && node.name === identifier) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (node.type === distExports.AST_NODE_TYPES.CallExpression) {
|
|
145
|
+
const { callee } = node;
|
|
146
|
+
if (callee.type === distExports.AST_NODE_TYPES.Identifier && callee.name === identifier) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (callee.type === distExports.AST_NODE_TYPES.MemberExpression) {
|
|
150
|
+
return expressionStartsWithIdentifier(callee.object, identifier);
|
|
151
|
+
}
|
|
152
|
+
if (callee.type === distExports.AST_NODE_TYPES.ChainExpression) {
|
|
153
|
+
return expressionStartsWithIdentifier(callee.expression, identifier);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (node.type === distExports.AST_NODE_TYPES.MemberExpression) {
|
|
157
|
+
return expressionStartsWithIdentifier(node.object, identifier);
|
|
158
|
+
}
|
|
159
|
+
if (node.type === distExports.AST_NODE_TYPES.ChainExpression) {
|
|
160
|
+
return expressionStartsWithIdentifier(node.expression, identifier);
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
140
164
|
function expressionUsesThis(expression) {
|
|
141
165
|
if (expression.type === distExports.AST_NODE_TYPES.AssignmentExpression) {
|
|
142
166
|
return isThisReceiver(expression.left);
|
|
@@ -144,9 +168,6 @@ function expressionUsesThis(expression) {
|
|
|
144
168
|
if (expression.type === distExports.AST_NODE_TYPES.CallExpression) {
|
|
145
169
|
return isThisReceiver(expression.callee);
|
|
146
170
|
}
|
|
147
|
-
if (expression.type === distExports.AST_NODE_TYPES.OptionalCallExpression) {
|
|
148
|
-
return isThisReceiver(expression.callee);
|
|
149
|
-
}
|
|
150
171
|
if (expression.type === distExports.AST_NODE_TYPES.UpdateExpression) {
|
|
151
172
|
return isThisReceiver(expression.argument);
|
|
152
173
|
}
|
|
@@ -210,6 +231,15 @@ function getStatementKind(node) {
|
|
|
210
231
|
}
|
|
211
232
|
return isSingleLine(node) ? "singleline-assignment" : "multiline-assignment";
|
|
212
233
|
}
|
|
234
|
+
if (isExpectExpression(node.expression)) {
|
|
235
|
+
return isSingleLine(node) ? "singleline-expect" : "multiline-expect";
|
|
236
|
+
}
|
|
237
|
+
if (isAssertExpression(node.expression)) {
|
|
238
|
+
return isSingleLine(node) ? "singleline-assert" : "multiline-assert";
|
|
239
|
+
}
|
|
240
|
+
if (isConsoleExpression(node.expression)) {
|
|
241
|
+
return isSingleLine(node) ? "singleline-console" : "multiline-console";
|
|
242
|
+
}
|
|
213
243
|
if (expressionUsesThis(node.expression)) {
|
|
214
244
|
return isSingleLine(node) ? "singleline-this" : "multiline-this";
|
|
215
245
|
}
|
|
@@ -233,12 +263,21 @@ function hasLineCommentBetween(prevNode, nextNode, sourceCode) {
|
|
|
233
263
|
return comment.range[0] >= prevNode.range[1] && comment.range[1] <= nextNode.range[0];
|
|
234
264
|
});
|
|
235
265
|
}
|
|
266
|
+
function isAssertExpression(expression) {
|
|
267
|
+
return expressionStartsWithIdentifier(expression, "assert");
|
|
268
|
+
}
|
|
269
|
+
function isConsoleExpression(expression) {
|
|
270
|
+
return expressionStartsWithIdentifier(expression, "console");
|
|
271
|
+
}
|
|
236
272
|
function isDirectivePrologue(node) {
|
|
237
273
|
if (node.expression.type !== distExports.AST_NODE_TYPES.Literal) {
|
|
238
274
|
return false;
|
|
239
275
|
}
|
|
240
276
|
return typeof node.expression.value === "string";
|
|
241
277
|
}
|
|
278
|
+
function isExpectExpression(expression) {
|
|
279
|
+
return expressionStartsWithIdentifier(expression, "expect");
|
|
280
|
+
}
|
|
242
281
|
function isOwnLineComment(comment, sourceCode) {
|
|
243
282
|
if (comment.type !== "Line") {
|
|
244
283
|
return false;
|
|
@@ -256,7 +295,7 @@ function isThisReceiver(node) {
|
|
|
256
295
|
if (node.type === distExports.AST_NODE_TYPES.ThisExpression) {
|
|
257
296
|
return true;
|
|
258
297
|
}
|
|
259
|
-
if (node.type === distExports.AST_NODE_TYPES.MemberExpression
|
|
298
|
+
if (node.type === distExports.AST_NODE_TYPES.MemberExpression) {
|
|
260
299
|
return isThisReceiver(node.object);
|
|
261
300
|
}
|
|
262
301
|
if (node.type === distExports.AST_NODE_TYPES.ChainExpression) {
|