eslint-config-seek 11.1.3 → 11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-seek",
3
- "version": "11.1.3",
3
+ "version": "11.2.0",
4
4
  "description": "ESLint configuration used by SEEK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,4 +1,4 @@
1
- /** This rule is copied from the original `eslint-plugin-cypress` so we can use the fork (which
1
+ /** This rule was copied from the original `eslint-plugin-cypress` so we can use the fork (which
2
2
  * supports eslint 8) while having the same recommended rules as the upstream
3
3
  * https://github.com/foretagsplatsen/eslint-plugin-cypress
4
4
  * https://github.com/cypress-io/eslint-plugin-cypress/blob/c626ad543f65babf1def5caabd1bc9bb9900d2c7/lib/rules/unsafe-to-chain-command.js
@@ -6,18 +6,21 @@
6
6
  // eslint-disable-next-line strict
7
7
  'use strict';
8
8
 
9
+ /** @type {import("eslint").Rule.RuleModule} */
9
10
  module.exports = {
10
11
  meta: {
12
+ type: 'problem',
11
13
  docs: {
12
- description: 'Actions should be in the end of chains, not in the middle',
14
+ description: 'Actions should be at the end of chains, not in the middle',
13
15
  category: 'Possible Errors',
14
16
  recommended: true,
15
17
  url: 'https://docs.cypress.io/guides/core-concepts/retry-ability#Actions-should-be-at-the-end-of-chains-not-the-middle',
16
18
  },
17
19
  schema: [],
20
+ fixable: 'code',
18
21
  messages: {
19
22
  unexpected:
20
- 'It is unsafe to chain further commands that rely on the subject after this command. It is best to split the chain, chaining again from `cy.` in a next command line.',
23
+ 'It is unsafe to chain further commands that rely on the subject after this command. It is best to split the chain, chaining again from `cy.` in the next command.',
21
24
  },
22
25
  },
23
26
  create(context) {
@@ -28,13 +31,28 @@ module.exports = {
28
31
  isActionUnsafeToChain(node) &&
29
32
  node.parent.type === 'MemberExpression'
30
33
  ) {
31
- context.report({ node, messageId: 'unexpected' });
34
+ context.report({
35
+ node,
36
+ messageId: 'unexpected',
37
+ fix: (fixer) => {
38
+ const { range: originalRange } = node.parent.property;
39
+
40
+ // Include the `.` before the identifier in the range
41
+ const adjustedRange = [originalRange[0] - 1, originalRange[1]];
42
+
43
+ return [
44
+ fixer.insertTextAfter(node, ';'),
45
+ fixer.insertTextBeforeRange(adjustedRange, 'cy'),
46
+ ];
47
+ },
48
+ });
32
49
  }
33
50
  },
34
51
  };
35
52
  },
36
53
  };
37
54
 
55
+ /** @param {import("eslint").Rule.Node} node */
38
56
  function isRootCypress(node) {
39
57
  while (node.type === 'CallExpression') {
40
58
  if (node.callee.type !== 'MemberExpression') {
@@ -55,6 +73,7 @@ function isRootCypress(node) {
55
73
  return false;
56
74
  }
57
75
 
76
+ /** @param {import("eslint").Rule.Node} node */
58
77
  function isActionUnsafeToChain(node) {
59
78
  // commands listed in the documentation with text: 'It is unsafe to chain further commands that rely on the subject after xxx'
60
79
  const unsafeToChainActions = [