@lvce-editor/eslint-plugin-e2e 17.5.0 → 17.7.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.
Files changed (2) hide show
  1. package/dist/index.js +106 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const meta$8 = {
1
+ const meta$9 = {
2
2
  docs: {
3
3
  description: 'Disallow direct click calls in E2E tests'
4
4
  },
@@ -10,7 +10,7 @@ const meta$8 = {
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$8 = context => {
13
+ const create$9 = context => {
14
14
  return {
15
15
  CallExpression(node) {
16
16
  if (!isDirectClickCall(node)) {
@@ -26,12 +26,12 @@ const create$8 = context => {
26
26
 
27
27
  const noDirectClick = {
28
28
  __proto__: null,
29
- create: create$8,
30
- meta: meta$8
29
+ create: create$9,
30
+ meta: meta$9
31
31
  };
32
32
 
33
33
  const allowedTypeImportSource = '@lvce-editor/test-with-playwright';
34
- const meta$7 = {
34
+ const meta$8 = {
35
35
  docs: {
36
36
  description: 'Disallow imports in e2e tests except type imports from @lvce-editor/test-with-playwright'
37
37
  },
@@ -49,7 +49,7 @@ const isAllowedTypeImport = node => {
49
49
  }
50
50
  return node.specifiers.length > 0 && node.specifiers.every(specifier => specifier.importKind === 'type');
51
51
  };
52
- const create$7 = context => {
52
+ const create$8 = context => {
53
53
  return {
54
54
  ImportDeclaration(node) {
55
55
  if (isAllowedTypeImport(node)) {
@@ -65,11 +65,11 @@ const create$7 = context => {
65
65
 
66
66
  const noImports = {
67
67
  __proto__: null,
68
- create: create$7,
69
- meta: meta$7
68
+ create: create$8,
69
+ meta: meta$8
70
70
  };
71
71
 
72
- const meta$6 = {
72
+ const meta$7 = {
73
73
  docs: {
74
74
  description: 'Disallow inline locator expressions inside expect calls'
75
75
  },
@@ -123,13 +123,13 @@ const containsInlineLocatorCall = node => {
123
123
  }
124
124
  return false;
125
125
  };
126
- const isExpectCall$1 = node => {
126
+ const isExpectCall$2 = node => {
127
127
  return node.callee.type === 'Identifier' && node.callee.name === 'expect';
128
128
  };
129
- const create$6 = context => {
129
+ const create$7 = context => {
130
130
  return {
131
131
  CallExpression(node) {
132
- if (!isExpectCall$1(node)) {
132
+ if (!isExpectCall$2(node)) {
133
133
  return;
134
134
  }
135
135
  const [firstArgument] = node.arguments;
@@ -146,11 +146,11 @@ const create$6 = context => {
146
146
 
147
147
  const noInlineLocatorInExpect = {
148
148
  __proto__: null,
149
- create: create$6,
150
- meta: meta$6
149
+ create: create$7,
150
+ meta: meta$7
151
151
  };
152
152
 
153
- const meta$5 = {
153
+ const meta$6 = {
154
154
  docs: {
155
155
  description: 'Disallow inline nth locator expressions inside expect calls'
156
156
  },
@@ -210,13 +210,13 @@ const containsInlineNthCall = node => {
210
210
  }
211
211
  return false;
212
212
  };
213
- const isExpectCall = node => {
213
+ const isExpectCall$1 = node => {
214
214
  return node.callee.type === 'Identifier' && node.callee.name === 'expect';
215
215
  };
216
- const create$5 = context => {
216
+ const create$6 = context => {
217
217
  return {
218
218
  CallExpression(node) {
219
- if (!isExpectCall(node)) {
219
+ if (!isExpectCall$1(node)) {
220
220
  return;
221
221
  }
222
222
  const [firstArgument] = node.arguments;
@@ -233,11 +233,11 @@ const create$5 = context => {
233
233
 
234
234
  const noInlineNthInExpect = {
235
235
  __proto__: null,
236
- create: create$5,
237
- meta: meta$5
236
+ create: create$6,
237
+ meta: meta$6
238
238
  };
239
239
 
240
- const meta$4 = {
240
+ const meta$5 = {
241
241
  docs: {
242
242
  description: 'Disallow lazy nth-based variable names for locator variables'
243
243
  },
@@ -298,7 +298,7 @@ const containsNthCall = node => {
298
298
  const hasLazyNthVariableName = node => {
299
299
  return isIdentifierNode$1(node) && lazyNthVariableNamePattern.test(node.name);
300
300
  };
301
- const create$4 = context => {
301
+ const create$5 = context => {
302
302
  return {
303
303
  VariableDeclarator(node) {
304
304
  if (!isVariableDeclaratorNode$1(node)) {
@@ -320,11 +320,11 @@ const create$4 = context => {
320
320
 
321
321
  const noLazyNthVariableName = {
322
322
  __proto__: null,
323
- create: create$4,
324
- meta: meta$4
323
+ create: create$5,
324
+ meta: meta$5
325
325
  };
326
326
 
327
- const meta$3 = {
327
+ const meta$4 = {
328
328
  docs: {
329
329
  description: 'Prefer destructuring e2e test api parameters directly'
330
330
  },
@@ -345,7 +345,7 @@ const isVariableDeclaratorNode = node => {
345
345
  const getParameterNames = node => {
346
346
  return node.params.filter(isIdentifierNode).map(param => param.name);
347
347
  };
348
- const create$3 = context => {
348
+ const create$4 = context => {
349
349
  const functionParameterNames = [];
350
350
  const enterFunction = node => {
351
351
  functionParameterNames.push([...getParameterNames(node)]);
@@ -381,11 +381,11 @@ const create$3 = context => {
381
381
 
382
382
  const preferDirectApiDestructuring = {
383
383
  __proto__: null,
384
- create: create$3,
385
- meta: meta$3
384
+ create: create$4,
385
+ meta: meta$4
386
386
  };
387
387
 
388
- const meta$2 = {
388
+ const meta$3 = {
389
389
  docs: {
390
390
  description: 'Prefer Command.executeExtensionCommand over Command.execute for extension commands'
391
391
  },
@@ -395,19 +395,19 @@ const meta$2 = {
395
395
  },
396
396
  type: 'suggestion'
397
397
  };
398
- const isIdentifier$1 = (node, name) => {
398
+ const isIdentifier$2 = (node, name) => {
399
399
  return node.type === 'Identifier' && node.name === name;
400
400
  };
401
401
  const isExtensionHostExecuteCommand = node => {
402
402
  return node.type === 'Literal' && node.value === 'ExtensionHost.executeCommand';
403
403
  };
404
404
  const isCommandExecuteCall = node => {
405
- return node.callee.type === 'MemberExpression' && !node.callee.computed && isIdentifier$1(node.callee.object, 'Command') && isIdentifier$1(node.callee.property, 'execute');
405
+ return node.callee.type === 'MemberExpression' && !node.callee.computed && isIdentifier$2(node.callee.object, 'Command') && isIdentifier$2(node.callee.property, 'execute');
406
406
  };
407
407
  const isExtensionCommandCall = node => {
408
408
  return isCommandExecuteCall(node) && node.arguments.length >= 2 && isExtensionHostExecuteCommand(node.arguments[0]);
409
409
  };
410
- const create$2 = context => {
410
+ const create$3 = context => {
411
411
  const {
412
412
  sourceCode
413
413
  } = context;
@@ -430,11 +430,11 @@ const create$2 = context => {
430
430
 
431
431
  const preferExecuteExtensionCommand = {
432
432
  __proto__: null,
433
- create: create$2,
434
- meta: meta$2
433
+ create: create$3,
434
+ meta: meta$3
435
435
  };
436
436
 
437
- const meta$1 = {
437
+ const meta$2 = {
438
438
  docs: {
439
439
  description: 'Prefer FileSystem.setFiles over adjacent FileSystem.writeFile calls'
440
440
  },
@@ -468,7 +468,7 @@ const reportAdjacentFileSystemWriteFiles = (context, statements) => {
468
468
  previousStatementWasWriteFile = isWriteFile;
469
469
  }
470
470
  };
471
- const create$1 = context => {
471
+ const create$2 = context => {
472
472
  return {
473
473
  BlockStatement(node) {
474
474
  reportAdjacentFileSystemWriteFiles(context, node.body);
@@ -478,11 +478,11 @@ const create$1 = context => {
478
478
 
479
479
  const preferFileSystemSetFiles = {
480
480
  __proto__: null,
481
- create: create$1,
482
- meta: meta$1
481
+ create: create$2,
482
+ meta: meta$2
483
483
  };
484
484
 
485
- const meta = {
485
+ const meta$1 = {
486
486
  docs: {
487
487
  description: 'Prefer import.meta.resolve over new URL(..., import.meta.url).toString()'
488
488
  },
@@ -491,22 +491,22 @@ const meta = {
491
491
  },
492
492
  type: 'suggestion'
493
493
  };
494
- const isIdentifier = (node, name) => {
494
+ const isIdentifier$1 = (node, name) => {
495
495
  return node.type === 'Identifier' && node.name === name;
496
496
  };
497
497
  const isImportMeta = node => {
498
- return node.type === 'MetaProperty' && isIdentifier(node.meta, 'import') && isIdentifier(node.property, 'meta');
498
+ return node.type === 'MetaProperty' && isIdentifier$1(node.meta, 'import') && isIdentifier$1(node.property, 'meta');
499
499
  };
500
500
  const isImportMetaUrl = node => {
501
- return node.type === 'MemberExpression' && !node.computed && isImportMeta(node.object) && isIdentifier(node.property, 'url');
501
+ return node.type === 'MemberExpression' && !node.computed && isImportMeta(node.object) && isIdentifier$1(node.property, 'url');
502
502
  };
503
503
  const isUrlConstructor = node => {
504
504
  return node.type === 'NewExpression' && node.callee.type === 'Identifier' && ['URL', 'Url'].includes(node.callee.name) && node.arguments.length >= 2 && isImportMetaUrl(node.arguments[1]);
505
505
  };
506
506
  const isNewUrlToStringCall = node => {
507
- return node.callee.type === 'MemberExpression' && !node.callee.computed && isIdentifier(node.callee.property, 'toString') && isUrlConstructor(node.callee.object);
507
+ return node.callee.type === 'MemberExpression' && !node.callee.computed && isIdentifier$1(node.callee.property, 'toString') && isUrlConstructor(node.callee.object);
508
508
  };
509
- const create = context => {
509
+ const create$1 = context => {
510
510
  return {
511
511
  CallExpression(node) {
512
512
  if (!isNewUrlToStringCall(node)) {
@@ -521,6 +521,64 @@ const create = context => {
521
521
  };
522
522
 
523
523
  const preferImportMetaResolve = {
524
+ __proto__: null,
525
+ create: create$1,
526
+ meta: meta$1
527
+ };
528
+
529
+ const meta = {
530
+ docs: {
531
+ description: 'Prefer toBeHidden over negated toBeVisible assertions'
532
+ },
533
+ fixable: 'code',
534
+ messages: {
535
+ preferToBeHidden: 'Use toBeHidden() instead of not.toBeVisible().'
536
+ },
537
+ type: 'suggestion'
538
+ };
539
+ const isIdentifier = (node, name) => {
540
+ return node.type === 'Identifier' && node.name === name;
541
+ };
542
+ const isExpectCall = node => {
543
+ if (node.type !== 'CallExpression') {
544
+ return false;
545
+ }
546
+ const {
547
+ callee
548
+ } = node;
549
+ return isIdentifier(callee, 'expect') || callee.type === 'MemberExpression' && !callee.computed && isIdentifier(callee.property, 'expect');
550
+ };
551
+ const getNegatedToBeVisibleCallee = node => {
552
+ const {
553
+ callee
554
+ } = node;
555
+ if (callee.type !== 'MemberExpression' || callee.computed || !isIdentifier(callee.property, 'toBeVisible') || callee.object.type !== 'MemberExpression' || callee.object.computed || !isIdentifier(callee.object.property, 'not') || !isExpectCall(callee.object.object)) {
556
+ return undefined;
557
+ }
558
+ return callee;
559
+ };
560
+ const create = context => {
561
+ const {
562
+ sourceCode
563
+ } = context;
564
+ return {
565
+ CallExpression(node) {
566
+ const callee = getNegatedToBeVisibleCallee(node);
567
+ if (!callee) {
568
+ return;
569
+ }
570
+ context.report({
571
+ fix(fixer) {
572
+ return fixer.replaceText(callee, `${sourceCode.getText(callee.object.object)}.toBeHidden`);
573
+ },
574
+ messageId: 'preferToBeHidden',
575
+ node: callee
576
+ });
577
+ }
578
+ };
579
+ };
580
+
581
+ const preferToBeHidden = {
524
582
  __proto__: null,
525
583
  create,
526
584
  meta
@@ -541,7 +599,8 @@ const plugin = {
541
599
  'prefer-direct-api-destructuring': preferDirectApiDestructuring,
542
600
  'prefer-execute-extension-command': preferExecuteExtensionCommand,
543
601
  'prefer-filesystem-set-files': preferFileSystemSetFiles,
544
- 'prefer-import-meta-resolve': preferImportMetaResolve
602
+ 'prefer-import-meta-resolve': preferImportMetaResolve,
603
+ 'prefer-to-be-hidden': preferToBeHidden
545
604
  }
546
605
  };
547
606
  const recommended = [{
@@ -558,7 +617,8 @@ const recommended = [{
558
617
  'e2e/prefer-direct-api-destructuring': 'error',
559
618
  'e2e/prefer-execute-extension-command': 'error',
560
619
  'e2e/prefer-filesystem-set-files': 'error',
561
- 'e2e/prefer-import-meta-resolve': 'error'
620
+ 'e2e/prefer-import-meta-resolve': 'error',
621
+ 'e2e/prefer-to-be-hidden': 'error'
562
622
  }
563
623
  }];
564
624
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-e2e",
3
- "version": "17.5.0",
3
+ "version": "17.7.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",