@saasmakers/eslint 1.0.13 → 1.0.16
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 +41 -0
- package/dist/index.mjs +41 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -139,6 +139,29 @@ 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 || node.type === index$1.distExports.AST_NODE_TYPES.OptionalCallExpression) {
|
|
147
|
+
if (node.callee.type === index$1.distExports.AST_NODE_TYPES.Identifier && node.callee.name === identifier) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if (node.callee.type === index$1.distExports.AST_NODE_TYPES.MemberExpression || node.callee.type === index$1.distExports.AST_NODE_TYPES.OptionalMemberExpression) {
|
|
151
|
+
return expressionStartsWithIdentifier(node.callee.object, identifier);
|
|
152
|
+
}
|
|
153
|
+
if (node.callee.type === index$1.distExports.AST_NODE_TYPES.ChainExpression) {
|
|
154
|
+
return expressionStartsWithIdentifier(node.callee.expression, identifier);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (node.type === index$1.distExports.AST_NODE_TYPES.MemberExpression || node.type === index$1.distExports.AST_NODE_TYPES.OptionalMemberExpression) {
|
|
158
|
+
return expressionStartsWithIdentifier(node.object, identifier);
|
|
159
|
+
}
|
|
160
|
+
if (node.type === index$1.distExports.AST_NODE_TYPES.ChainExpression) {
|
|
161
|
+
return expressionStartsWithIdentifier(node.expression, identifier);
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
142
165
|
function expressionUsesThis(expression) {
|
|
143
166
|
if (expression.type === index$1.distExports.AST_NODE_TYPES.AssignmentExpression) {
|
|
144
167
|
return isThisReceiver(expression.left);
|
|
@@ -212,6 +235,15 @@ function getStatementKind(node) {
|
|
|
212
235
|
}
|
|
213
236
|
return isSingleLine(node) ? "singleline-assignment" : "multiline-assignment";
|
|
214
237
|
}
|
|
238
|
+
if (isExpectExpression(node.expression)) {
|
|
239
|
+
return isSingleLine(node) ? "singleline-expect" : "multiline-expect";
|
|
240
|
+
}
|
|
241
|
+
if (isAssertExpression(node.expression)) {
|
|
242
|
+
return isSingleLine(node) ? "singleline-assert" : "multiline-assert";
|
|
243
|
+
}
|
|
244
|
+
if (isConsoleExpression(node.expression)) {
|
|
245
|
+
return isSingleLine(node) ? "singleline-console" : "multiline-console";
|
|
246
|
+
}
|
|
215
247
|
if (expressionUsesThis(node.expression)) {
|
|
216
248
|
return isSingleLine(node) ? "singleline-this" : "multiline-this";
|
|
217
249
|
}
|
|
@@ -235,12 +267,21 @@ function hasLineCommentBetween(prevNode, nextNode, sourceCode) {
|
|
|
235
267
|
return comment.range[0] >= prevNode.range[1] && comment.range[1] <= nextNode.range[0];
|
|
236
268
|
});
|
|
237
269
|
}
|
|
270
|
+
function isAssertExpression(expression) {
|
|
271
|
+
return expressionStartsWithIdentifier(expression, "assert");
|
|
272
|
+
}
|
|
273
|
+
function isConsoleExpression(expression) {
|
|
274
|
+
return expressionStartsWithIdentifier(expression, "console");
|
|
275
|
+
}
|
|
238
276
|
function isDirectivePrologue(node) {
|
|
239
277
|
if (node.expression.type !== index$1.distExports.AST_NODE_TYPES.Literal) {
|
|
240
278
|
return false;
|
|
241
279
|
}
|
|
242
280
|
return typeof node.expression.value === "string";
|
|
243
281
|
}
|
|
282
|
+
function isExpectExpression(expression) {
|
|
283
|
+
return expressionStartsWithIdentifier(expression, "expect");
|
|
284
|
+
}
|
|
244
285
|
function isOwnLineComment(comment, sourceCode) {
|
|
245
286
|
if (comment.type !== "Line") {
|
|
246
287
|
return false;
|
package/dist/index.mjs
CHANGED
|
@@ -137,6 +137,29 @@ 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 || node.type === distExports.AST_NODE_TYPES.OptionalCallExpression) {
|
|
145
|
+
if (node.callee.type === distExports.AST_NODE_TYPES.Identifier && node.callee.name === identifier) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
if (node.callee.type === distExports.AST_NODE_TYPES.MemberExpression || node.callee.type === distExports.AST_NODE_TYPES.OptionalMemberExpression) {
|
|
149
|
+
return expressionStartsWithIdentifier(node.callee.object, identifier);
|
|
150
|
+
}
|
|
151
|
+
if (node.callee.type === distExports.AST_NODE_TYPES.ChainExpression) {
|
|
152
|
+
return expressionStartsWithIdentifier(node.callee.expression, identifier);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (node.type === distExports.AST_NODE_TYPES.MemberExpression || node.type === distExports.AST_NODE_TYPES.OptionalMemberExpression) {
|
|
156
|
+
return expressionStartsWithIdentifier(node.object, identifier);
|
|
157
|
+
}
|
|
158
|
+
if (node.type === distExports.AST_NODE_TYPES.ChainExpression) {
|
|
159
|
+
return expressionStartsWithIdentifier(node.expression, identifier);
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
140
163
|
function expressionUsesThis(expression) {
|
|
141
164
|
if (expression.type === distExports.AST_NODE_TYPES.AssignmentExpression) {
|
|
142
165
|
return isThisReceiver(expression.left);
|
|
@@ -210,6 +233,15 @@ function getStatementKind(node) {
|
|
|
210
233
|
}
|
|
211
234
|
return isSingleLine(node) ? "singleline-assignment" : "multiline-assignment";
|
|
212
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
|
+
}
|
|
213
245
|
if (expressionUsesThis(node.expression)) {
|
|
214
246
|
return isSingleLine(node) ? "singleline-this" : "multiline-this";
|
|
215
247
|
}
|
|
@@ -233,12 +265,21 @@ function hasLineCommentBetween(prevNode, nextNode, sourceCode) {
|
|
|
233
265
|
return comment.range[0] >= prevNode.range[1] && comment.range[1] <= nextNode.range[0];
|
|
234
266
|
});
|
|
235
267
|
}
|
|
268
|
+
function isAssertExpression(expression) {
|
|
269
|
+
return expressionStartsWithIdentifier(expression, "assert");
|
|
270
|
+
}
|
|
271
|
+
function isConsoleExpression(expression) {
|
|
272
|
+
return expressionStartsWithIdentifier(expression, "console");
|
|
273
|
+
}
|
|
236
274
|
function isDirectivePrologue(node) {
|
|
237
275
|
if (node.expression.type !== distExports.AST_NODE_TYPES.Literal) {
|
|
238
276
|
return false;
|
|
239
277
|
}
|
|
240
278
|
return typeof node.expression.value === "string";
|
|
241
279
|
}
|
|
280
|
+
function isExpectExpression(expression) {
|
|
281
|
+
return expressionStartsWithIdentifier(expression, "expect");
|
|
282
|
+
}
|
|
242
283
|
function isOwnLineComment(comment, sourceCode) {
|
|
243
284
|
if (comment.type !== "Line") {
|
|
244
285
|
return false;
|