@lvce-editor/eslint-plugin-e2e 14.1.0 → 14.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 +69 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const meta$
|
|
1
|
+
const meta$6 = {
|
|
2
2
|
docs: {
|
|
3
3
|
description: 'Disallow direct click calls in E2E tests'
|
|
4
4
|
},
|
|
@@ -10,7 +10,7 @@ const meta$5 = {
|
|
|
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$6 = context => {
|
|
14
14
|
return {
|
|
15
15
|
CallExpression(node) {
|
|
16
16
|
if (!isDirectClickCall(node)) {
|
|
@@ -26,11 +26,11 @@ const create$5 = context => {
|
|
|
26
26
|
|
|
27
27
|
const noDirectClick = {
|
|
28
28
|
__proto__: null,
|
|
29
|
-
create: create$
|
|
30
|
-
meta: meta$
|
|
29
|
+
create: create$6,
|
|
30
|
+
meta: meta$6
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const meta$
|
|
33
|
+
const meta$5 = {
|
|
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$5 = context => {
|
|
91
91
|
return {
|
|
92
92
|
CallExpression(node) {
|
|
93
93
|
if (!isExpectCall$1(node)) {
|
|
@@ -107,11 +107,11 @@ const create$4 = context => {
|
|
|
107
107
|
|
|
108
108
|
const noInlineLocatorInExpect = {
|
|
109
109
|
__proto__: null,
|
|
110
|
-
create: create$
|
|
111
|
-
meta: meta$
|
|
110
|
+
create: create$5,
|
|
111
|
+
meta: meta$5
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
const meta$
|
|
114
|
+
const meta$4 = {
|
|
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$4 = context => {
|
|
178
178
|
return {
|
|
179
179
|
CallExpression(node) {
|
|
180
180
|
if (!isExpectCall(node)) {
|
|
@@ -194,11 +194,11 @@ const create$3 = context => {
|
|
|
194
194
|
|
|
195
195
|
const noInlineNthInExpect = {
|
|
196
196
|
__proto__: null,
|
|
197
|
-
create: create$
|
|
198
|
-
meta: meta$
|
|
197
|
+
create: create$4,
|
|
198
|
+
meta: meta$4
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
-
const meta$
|
|
201
|
+
const meta$3 = {
|
|
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$3 = context => {
|
|
263
263
|
return {
|
|
264
264
|
VariableDeclarator(node) {
|
|
265
265
|
if (!isVariableDeclaratorNode$1(node)) {
|
|
@@ -281,11 +281,11 @@ const create$2 = context => {
|
|
|
281
281
|
|
|
282
282
|
const noLazyNthVariableName = {
|
|
283
283
|
__proto__: null,
|
|
284
|
-
create: create$
|
|
285
|
-
meta: meta$
|
|
284
|
+
create: create$3,
|
|
285
|
+
meta: meta$3
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
const meta$
|
|
288
|
+
const meta$2 = {
|
|
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$2 = context => {
|
|
310
310
|
const functionParameterNames = [];
|
|
311
311
|
const enterFunction = node => {
|
|
312
312
|
functionParameterNames.push([...getParameterNames(node)]);
|
|
@@ -341,6 +341,55 @@ const create$1 = context => {
|
|
|
341
341
|
};
|
|
342
342
|
|
|
343
343
|
const preferDirectApiDestructuring = {
|
|
344
|
+
__proto__: null,
|
|
345
|
+
create: create$2,
|
|
346
|
+
meta: meta$2
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const meta$1 = {
|
|
350
|
+
docs: {
|
|
351
|
+
description: 'Prefer Command.executeExtensionCommand over Command.execute for extension commands'
|
|
352
|
+
},
|
|
353
|
+
fixable: 'code',
|
|
354
|
+
messages: {
|
|
355
|
+
preferExecuteExtensionCommand: "Use Command.executeExtensionCommand(...) instead of Command.execute('ExtensionHost.executeCommand', ...)."
|
|
356
|
+
},
|
|
357
|
+
type: 'suggestion'
|
|
358
|
+
};
|
|
359
|
+
const isIdentifier$1 = (node, name) => {
|
|
360
|
+
return node.type === 'Identifier' && node.name === name;
|
|
361
|
+
};
|
|
362
|
+
const isExtensionHostExecuteCommand = node => {
|
|
363
|
+
return node.type === 'Literal' && node.value === 'ExtensionHost.executeCommand';
|
|
364
|
+
};
|
|
365
|
+
const isCommandExecuteCall = node => {
|
|
366
|
+
return node.callee.type === 'MemberExpression' && !node.callee.computed && isIdentifier$1(node.callee.object, 'Command') && isIdentifier$1(node.callee.property, 'execute');
|
|
367
|
+
};
|
|
368
|
+
const isExtensionCommandCall = node => {
|
|
369
|
+
return isCommandExecuteCall(node) && node.arguments.length >= 2 && isExtensionHostExecuteCommand(node.arguments[0]);
|
|
370
|
+
};
|
|
371
|
+
const create$1 = context => {
|
|
372
|
+
const {
|
|
373
|
+
sourceCode
|
|
374
|
+
} = context;
|
|
375
|
+
return {
|
|
376
|
+
CallExpression(node) {
|
|
377
|
+
if (!isExtensionCommandCall(node)) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
context.report({
|
|
381
|
+
fix(fixer) {
|
|
382
|
+
const args = node.arguments.slice(1).map(argument => sourceCode.getText(argument));
|
|
383
|
+
return fixer.replaceText(node, `Command.executeExtensionCommand(${args.join(', ')})`);
|
|
384
|
+
},
|
|
385
|
+
messageId: 'preferExecuteExtensionCommand',
|
|
386
|
+
node
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const preferExecuteExtensionCommand = {
|
|
344
393
|
__proto__: null,
|
|
345
394
|
create: create$1,
|
|
346
395
|
meta: meta$1
|
|
@@ -402,6 +451,7 @@ const plugin = {
|
|
|
402
451
|
'no-inline-nth-in-expect': noInlineNthInExpect,
|
|
403
452
|
'no-lazy-nth-variable-name': noLazyNthVariableName,
|
|
404
453
|
'prefer-direct-api-destructuring': preferDirectApiDestructuring,
|
|
454
|
+
'prefer-execute-extension-command': preferExecuteExtensionCommand,
|
|
405
455
|
'prefer-import-meta-resolve': preferImportMetaResolve
|
|
406
456
|
}
|
|
407
457
|
};
|
|
@@ -416,6 +466,7 @@ const recommended = [{
|
|
|
416
466
|
'e2e/no-inline-nth-in-expect': 'error',
|
|
417
467
|
'e2e/no-lazy-nth-variable-name': 'error',
|
|
418
468
|
'e2e/prefer-direct-api-destructuring': 'error',
|
|
469
|
+
'e2e/prefer-execute-extension-command': 'error',
|
|
419
470
|
'e2e/prefer-import-meta-resolve': 'error'
|
|
420
471
|
}
|
|
421
472
|
}];
|