@lvce-editor/eslint-plugin-e2e 16.3.0 → 16.5.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 +43 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const meta$7 = {
1
+ const meta$8 = {
2
2
  docs: {
3
3
  description: 'Disallow direct click calls in E2E tests'
4
4
  },
@@ -10,7 +10,7 @@ const meta$7 = {
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$7 = context => {
13
+ const create$8 = context => {
14
14
  return {
15
15
  CallExpression(node) {
16
16
  if (!isDirectClickCall(node)) {
@@ -25,6 +25,45 @@ const create$7 = context => {
25
25
  };
26
26
 
27
27
  const noDirectClick = {
28
+ __proto__: null,
29
+ create: create$8,
30
+ meta: meta$8
31
+ };
32
+
33
+ const allowedTypeImportSource = '@lvce-editor/test-with-playwright';
34
+ const meta$7 = {
35
+ docs: {
36
+ description: 'Disallow imports in e2e tests except type imports from @lvce-editor/test-with-playwright'
37
+ },
38
+ messages: {
39
+ noImports: 'E2E tests must be self-contained. Only type imports from @lvce-editor/test-with-playwright are allowed.'
40
+ },
41
+ type: 'problem'
42
+ };
43
+ const isAllowedTypeImport = node => {
44
+ if (node.source.value !== allowedTypeImportSource) {
45
+ return false;
46
+ }
47
+ if (node.importKind === 'type') {
48
+ return true;
49
+ }
50
+ return node.specifiers.length > 0 && node.specifiers.every(specifier => specifier.importKind === 'type');
51
+ };
52
+ const create$7 = context => {
53
+ return {
54
+ ImportDeclaration(node) {
55
+ if (isAllowedTypeImport(node)) {
56
+ return;
57
+ }
58
+ context.report({
59
+ messageId: 'noImports',
60
+ node
61
+ });
62
+ }
63
+ };
64
+ };
65
+
66
+ const noImports = {
28
67
  __proto__: null,
29
68
  create: create$7,
30
69
  meta: meta$7
@@ -495,6 +534,7 @@ const plugin = {
495
534
  },
496
535
  rules: {
497
536
  'no-direct-click': noDirectClick,
537
+ 'no-imports': noImports,
498
538
  'no-inline-locator-in-expect': noInlineLocatorInExpect,
499
539
  'no-inline-nth-in-expect': noInlineNthInExpect,
500
540
  'no-lazy-nth-variable-name': noLazyNthVariableName,
@@ -511,6 +551,7 @@ const recommended = [{
511
551
  },
512
552
  rules: {
513
553
  'e2e/no-direct-click': 'error',
554
+ 'e2e/no-imports': 'error',
514
555
  'e2e/no-inline-locator-in-expect': 'error',
515
556
  'e2e/no-inline-nth-in-expect': 'error',
516
557
  'e2e/no-lazy-nth-variable-name': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-e2e",
3
- "version": "16.3.0",
3
+ "version": "16.5.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",