@lvce-editor/eslint-plugin-e2e 16.0.0 → 16.2.0
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.js +72 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const meta$
|
|
1
|
+
const meta$7 = {
|
|
2
2
|
docs: {
|
|
3
3
|
description: 'Disallow direct click calls in E2E tests'
|
|
4
4
|
},
|
|
@@ -10,7 +10,7 @@ const meta$6 = {
|
|
|
10
10
|
const isDirectClickCall = node => {
|
|
11
11
|
return node.callee.type === 'MemberExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'click';
|
|
12
12
|
};
|
|
13
|
-
const create$
|
|
13
|
+
const create$7 = context => {
|
|
14
14
|
return {
|
|
15
15
|
CallExpression(node) {
|
|
16
16
|
if (!isDirectClickCall(node)) {
|
|
@@ -26,11 +26,11 @@ const create$6 = context => {
|
|
|
26
26
|
|
|
27
27
|
const noDirectClick = {
|
|
28
28
|
__proto__: null,
|
|
29
|
-
create: create$
|
|
30
|
-
meta: meta$
|
|
29
|
+
create: create$7,
|
|
30
|
+
meta: meta$7
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const meta$
|
|
33
|
+
const meta$6 = {
|
|
34
34
|
docs: {
|
|
35
35
|
description: 'Disallow inline locator expressions inside expect calls'
|
|
36
36
|
},
|
|
@@ -87,7 +87,7 @@ const containsInlineLocatorCall = node => {
|
|
|
87
87
|
const isExpectCall$1 = node => {
|
|
88
88
|
return node.callee.type === 'Identifier' && node.callee.name === 'expect';
|
|
89
89
|
};
|
|
90
|
-
const create$
|
|
90
|
+
const create$6 = context => {
|
|
91
91
|
return {
|
|
92
92
|
CallExpression(node) {
|
|
93
93
|
if (!isExpectCall$1(node)) {
|
|
@@ -107,11 +107,11 @@ const create$5 = context => {
|
|
|
107
107
|
|
|
108
108
|
const noInlineLocatorInExpect = {
|
|
109
109
|
__proto__: null,
|
|
110
|
-
create: create$
|
|
111
|
-
meta: meta$
|
|
110
|
+
create: create$6,
|
|
111
|
+
meta: meta$6
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
const meta$
|
|
114
|
+
const meta$5 = {
|
|
115
115
|
docs: {
|
|
116
116
|
description: 'Disallow inline nth locator expressions inside expect calls'
|
|
117
117
|
},
|
|
@@ -174,7 +174,7 @@ const containsInlineNthCall = node => {
|
|
|
174
174
|
const isExpectCall = node => {
|
|
175
175
|
return node.callee.type === 'Identifier' && node.callee.name === 'expect';
|
|
176
176
|
};
|
|
177
|
-
const create$
|
|
177
|
+
const create$5 = context => {
|
|
178
178
|
return {
|
|
179
179
|
CallExpression(node) {
|
|
180
180
|
if (!isExpectCall(node)) {
|
|
@@ -194,11 +194,11 @@ const create$4 = context => {
|
|
|
194
194
|
|
|
195
195
|
const noInlineNthInExpect = {
|
|
196
196
|
__proto__: null,
|
|
197
|
-
create: create$
|
|
198
|
-
meta: meta$
|
|
197
|
+
create: create$5,
|
|
198
|
+
meta: meta$5
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
-
const meta$
|
|
201
|
+
const meta$4 = {
|
|
202
202
|
docs: {
|
|
203
203
|
description: 'Disallow lazy nth-based variable names for locator variables'
|
|
204
204
|
},
|
|
@@ -259,7 +259,7 @@ const containsNthCall = node => {
|
|
|
259
259
|
const hasLazyNthVariableName = node => {
|
|
260
260
|
return isIdentifierNode$1(node) && lazyNthVariableNamePattern.test(node.name);
|
|
261
261
|
};
|
|
262
|
-
const create$
|
|
262
|
+
const create$4 = context => {
|
|
263
263
|
return {
|
|
264
264
|
VariableDeclarator(node) {
|
|
265
265
|
if (!isVariableDeclaratorNode$1(node)) {
|
|
@@ -281,11 +281,11 @@ const create$3 = context => {
|
|
|
281
281
|
|
|
282
282
|
const noLazyNthVariableName = {
|
|
283
283
|
__proto__: null,
|
|
284
|
-
create: create$
|
|
285
|
-
meta: meta$
|
|
284
|
+
create: create$4,
|
|
285
|
+
meta: meta$4
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
const meta$
|
|
288
|
+
const meta$3 = {
|
|
289
289
|
docs: {
|
|
290
290
|
description: 'Prefer destructuring e2e test api parameters directly'
|
|
291
291
|
},
|
|
@@ -306,7 +306,7 @@ const isVariableDeclaratorNode = node => {
|
|
|
306
306
|
const getParameterNames = node => {
|
|
307
307
|
return node.params.filter(isIdentifierNode).map(param => param.name);
|
|
308
308
|
};
|
|
309
|
-
const create$
|
|
309
|
+
const create$3 = context => {
|
|
310
310
|
const functionParameterNames = [];
|
|
311
311
|
const enterFunction = node => {
|
|
312
312
|
functionParameterNames.push([...getParameterNames(node)]);
|
|
@@ -342,11 +342,11 @@ const create$2 = context => {
|
|
|
342
342
|
|
|
343
343
|
const preferDirectApiDestructuring = {
|
|
344
344
|
__proto__: null,
|
|
345
|
-
create: create$
|
|
346
|
-
meta: meta$
|
|
345
|
+
create: create$3,
|
|
346
|
+
meta: meta$3
|
|
347
347
|
};
|
|
348
348
|
|
|
349
|
-
const meta$
|
|
349
|
+
const meta$2 = {
|
|
350
350
|
docs: {
|
|
351
351
|
description: 'Prefer Command.executeExtensionCommand over Command.execute for extension commands'
|
|
352
352
|
},
|
|
@@ -368,7 +368,7 @@ const isCommandExecuteCall = node => {
|
|
|
368
368
|
const isExtensionCommandCall = node => {
|
|
369
369
|
return isCommandExecuteCall(node) && node.arguments.length >= 2 && isExtensionHostExecuteCommand(node.arguments[0]);
|
|
370
370
|
};
|
|
371
|
-
const create$
|
|
371
|
+
const create$2 = context => {
|
|
372
372
|
const {
|
|
373
373
|
sourceCode
|
|
374
374
|
} = context;
|
|
@@ -390,6 +390,54 @@ const create$1 = context => {
|
|
|
390
390
|
};
|
|
391
391
|
|
|
392
392
|
const preferExecuteExtensionCommand = {
|
|
393
|
+
__proto__: null,
|
|
394
|
+
create: create$2,
|
|
395
|
+
meta: meta$2
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
const meta$1 = {
|
|
399
|
+
docs: {
|
|
400
|
+
description: 'Prefer FileSystem.setFiles over adjacent FileSystem.writeFile calls'
|
|
401
|
+
},
|
|
402
|
+
messages: {
|
|
403
|
+
preferFileSystemSetFiles: 'Use FileSystem.setFiles([...fileItems]) instead of multiple adjacent FileSystem.writeFile calls so files can be written in parallel.'
|
|
404
|
+
},
|
|
405
|
+
type: 'suggestion'
|
|
406
|
+
};
|
|
407
|
+
const isFileSystemWriteFileCall = node => {
|
|
408
|
+
if (node.type !== 'CallExpression') {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
const {
|
|
412
|
+
callee
|
|
413
|
+
} = node;
|
|
414
|
+
return callee.type === 'MemberExpression' && callee.object.type === 'Identifier' && callee.object.name === 'FileSystem' && callee.property.type === 'Identifier' && callee.property.name === 'writeFile';
|
|
415
|
+
};
|
|
416
|
+
const isAwaitedFileSystemWriteFile = node => {
|
|
417
|
+
return node.type === 'ExpressionStatement' && node.expression.type === 'AwaitExpression' && isFileSystemWriteFileCall(node.expression.argument);
|
|
418
|
+
};
|
|
419
|
+
const reportAdjacentFileSystemWriteFiles = (context, statements) => {
|
|
420
|
+
let previousStatementWasWriteFile = false;
|
|
421
|
+
for (const statement of statements) {
|
|
422
|
+
const isWriteFile = isAwaitedFileSystemWriteFile(statement);
|
|
423
|
+
if (isWriteFile && previousStatementWasWriteFile) {
|
|
424
|
+
context.report({
|
|
425
|
+
messageId: 'preferFileSystemSetFiles',
|
|
426
|
+
node: statement
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
previousStatementWasWriteFile = isWriteFile;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
const create$1 = context => {
|
|
433
|
+
return {
|
|
434
|
+
BlockStatement(node) {
|
|
435
|
+
reportAdjacentFileSystemWriteFiles(context, node.body);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const preferFileSystemSetFiles = {
|
|
393
441
|
__proto__: null,
|
|
394
442
|
create: create$1,
|
|
395
443
|
meta: meta$1
|
|
@@ -452,6 +500,7 @@ const plugin = {
|
|
|
452
500
|
'no-lazy-nth-variable-name': noLazyNthVariableName,
|
|
453
501
|
'prefer-direct-api-destructuring': preferDirectApiDestructuring,
|
|
454
502
|
'prefer-execute-extension-command': preferExecuteExtensionCommand,
|
|
503
|
+
'prefer-filesystem-set-files': preferFileSystemSetFiles,
|
|
455
504
|
'prefer-import-meta-resolve': preferImportMetaResolve
|
|
456
505
|
}
|
|
457
506
|
};
|
|
@@ -467,6 +516,7 @@ const recommended = [{
|
|
|
467
516
|
'e2e/no-lazy-nth-variable-name': 'error',
|
|
468
517
|
'e2e/prefer-direct-api-destructuring': 'error',
|
|
469
518
|
'e2e/prefer-execute-extension-command': 'error',
|
|
519
|
+
'e2e/prefer-filesystem-set-files': 'error',
|
|
470
520
|
'e2e/prefer-import-meta-resolve': 'error'
|
|
471
521
|
}
|
|
472
522
|
}];
|