@lvce-editor/eslint-plugin-e2e 17.8.0 → 18.1.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 +77 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const meta$9 = {
1
+ const meta$a = {
2
2
  docs: {
3
3
  description: 'Disallow direct click calls in E2E tests'
4
4
  },
@@ -10,7 +10,7 @@ const meta$9 = {
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$9 = context => {
13
+ const create$a = context => {
14
14
  return {
15
15
  CallExpression(node) {
16
16
  if (!isDirectClickCall(node)) {
@@ -26,12 +26,12 @@ const create$9 = context => {
26
26
 
27
27
  const noDirectClick = {
28
28
  __proto__: null,
29
- create: create$9,
30
- meta: meta$9
29
+ create: create$a,
30
+ meta: meta$a
31
31
  };
32
32
 
33
33
  const allowedTypeImportSource = '@lvce-editor/test-with-playwright';
34
- const meta$8 = {
34
+ const meta$9 = {
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$8 = context => {
52
+ const create$9 = context => {
53
53
  return {
54
54
  ImportDeclaration(node) {
55
55
  if (isAllowedTypeImport(node)) {
@@ -65,11 +65,11 @@ const create$8 = context => {
65
65
 
66
66
  const noImports = {
67
67
  __proto__: null,
68
- create: create$8,
69
- meta: meta$8
68
+ create: create$9,
69
+ meta: meta$9
70
70
  };
71
71
 
72
- const meta$7 = {
72
+ const meta$8 = {
73
73
  docs: {
74
74
  description: 'Disallow inline locator expressions inside expect calls'
75
75
  },
@@ -126,7 +126,7 @@ const containsInlineLocatorCall = node => {
126
126
  const isExpectCall$2 = node => {
127
127
  return node.callee.type === 'Identifier' && node.callee.name === 'expect';
128
128
  };
129
- const create$7 = context => {
129
+ const create$8 = context => {
130
130
  return {
131
131
  CallExpression(node) {
132
132
  if (!isExpectCall$2(node)) {
@@ -146,11 +146,11 @@ const create$7 = context => {
146
146
 
147
147
  const noInlineLocatorInExpect = {
148
148
  __proto__: null,
149
- create: create$7,
150
- meta: meta$7
149
+ create: create$8,
150
+ meta: meta$8
151
151
  };
152
152
 
153
- const meta$6 = {
153
+ const meta$7 = {
154
154
  docs: {
155
155
  description: 'Disallow inline nth locator expressions inside expect calls'
156
156
  },
@@ -213,7 +213,7 @@ const containsInlineNthCall = node => {
213
213
  const isExpectCall$1 = node => {
214
214
  return node.callee.type === 'Identifier' && node.callee.name === 'expect';
215
215
  };
216
- const create$6 = context => {
216
+ const create$7 = context => {
217
217
  return {
218
218
  CallExpression(node) {
219
219
  if (!isExpectCall$1(node)) {
@@ -233,11 +233,11 @@ const create$6 = context => {
233
233
 
234
234
  const noInlineNthInExpect = {
235
235
  __proto__: null,
236
- create: create$6,
237
- meta: meta$6
236
+ create: create$7,
237
+ meta: meta$7
238
238
  };
239
239
 
240
- const meta$5 = {
240
+ const meta$6 = {
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$5 = context => {
301
+ const create$6 = context => {
302
302
  return {
303
303
  VariableDeclarator(node) {
304
304
  if (!isVariableDeclaratorNode$1(node)) {
@@ -319,6 +319,63 @@ const create$5 = context => {
319
319
  };
320
320
 
321
321
  const noLazyNthVariableName = {
322
+ __proto__: null,
323
+ create: create$6,
324
+ meta: meta$6
325
+ };
326
+
327
+ const meta$5 = {
328
+ docs: {
329
+ description: 'Disallow exporting skip with a value of zero'
330
+ },
331
+ fixable: 'code',
332
+ messages: {
333
+ noSkipZero: 'Omit the skip export when the test should run.'
334
+ },
335
+ type: 'suggestion'
336
+ };
337
+ const isSkipZeroDeclaration = node => {
338
+ const {
339
+ declaration
340
+ } = node;
341
+ if (declaration?.type !== 'VariableDeclaration' || declaration.kind !== 'const' || declaration.declarations.length !== 1) {
342
+ return false;
343
+ }
344
+ const [{
345
+ id,
346
+ init
347
+ }] = declaration.declarations;
348
+ return id.type === 'Identifier' && id.name === 'skip' && init?.type === 'Literal' && init.value === 0;
349
+ };
350
+ const getRemovalRange = (node, sourceCode) => {
351
+ if (!node.range) {
352
+ return undefined;
353
+ }
354
+ const trailingLineBreaks = /^(?:[\t ]*\r?\n)+/.exec(sourceCode.text.slice(node.range[1]))?.[0].length ?? 0;
355
+ return [node.range[0], node.range[1] + trailingLineBreaks];
356
+ };
357
+ const create$5 = context => {
358
+ const {
359
+ sourceCode
360
+ } = context;
361
+ return {
362
+ ExportNamedDeclaration(node) {
363
+ if (!isSkipZeroDeclaration(node)) {
364
+ return;
365
+ }
366
+ context.report({
367
+ fix(fixer) {
368
+ const range = getRemovalRange(node, sourceCode);
369
+ return range ? fixer.removeRange(range) : fixer.remove(node);
370
+ },
371
+ messageId: 'noSkipZero',
372
+ node
373
+ });
374
+ }
375
+ };
376
+ };
377
+
378
+ const noSkipZero = {
322
379
  __proto__: null,
323
380
  create: create$5,
324
381
  meta: meta$5
@@ -596,6 +653,7 @@ const plugin = {
596
653
  'no-inline-locator-in-expect': noInlineLocatorInExpect,
597
654
  'no-inline-nth-in-expect': noInlineNthInExpect,
598
655
  'no-lazy-nth-variable-name': noLazyNthVariableName,
656
+ 'no-skip-zero': noSkipZero,
599
657
  'prefer-direct-api-destructuring': preferDirectApiDestructuring,
600
658
  'prefer-execute-extension-command': preferExecuteExtensionCommand,
601
659
  'prefer-filesystem-set-files': preferFileSystemSetFiles,
@@ -614,6 +672,7 @@ const recommended = [{
614
672
  'e2e/no-inline-locator-in-expect': 'error',
615
673
  'e2e/no-inline-nth-in-expect': 'error',
616
674
  'e2e/no-lazy-nth-variable-name': 'error',
675
+ 'e2e/no-skip-zero': 'error',
617
676
  'e2e/prefer-direct-api-destructuring': 'error',
618
677
  'e2e/prefer-execute-extension-command': 'error',
619
678
  'e2e/prefer-filesystem-set-files': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-e2e",
3
- "version": "17.8.0",
3
+ "version": "18.1.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",