eslint-config-seek 0.0.0-rulesdir-20230604234812 → 0.0.0-rulesdir-20230605003131

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/base.js CHANGED
@@ -5,7 +5,7 @@ const OFF = 0;
5
5
  const ERROR = 2;
6
6
 
7
7
  const rulesDirPlugin = require('eslint-plugin-rulesdir');
8
- rulesDirPlugin.RULES_DIR = 'rules'; // (an example folder where your rules might be stored)
8
+ rulesDirPlugin.RULES_DIR = path.resolve('rules', path.dirname(__filename));
9
9
 
10
10
  const baseRules = {
11
11
  // Possible Errors
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "eslint-config-seek",
3
- "version": "0.0.0-rulesdir-20230604234812",
3
+ "version": "0.0.0-rulesdir-20230605003131",
4
4
  "description": "ESLint configuration used by SEEK",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "index.js",
8
8
  "base.js",
9
9
  "extensions.js",
10
- "eslint-local-rules/*"
10
+ "rules/*"
11
11
  ],
12
12
  "repository": {
13
13
  "type": "git",
@@ -0,0 +1,88 @@
1
+ /** This rule is copied from the original `eslint-plugin-cypress` so we can use the fork (which
2
+ * supports eslint 8) while having the same recommended rules as the upstream
3
+ * https://github.com/foretagsplatsen/eslint-plugin-cypress
4
+ * https://github.com/cypress-io/eslint-plugin-cypress/blob/c626ad543f65babf1def5caabd1bc9bb9900d2c7/lib/rules/unsafe-to-chain-command.js
5
+ */
6
+ // eslint-disable-next-line strict
7
+ 'use strict';
8
+
9
+ module.exports = {
10
+ meta: {
11
+ docs: {
12
+ description: 'Actions should be in the end of chains, not in the middle',
13
+ category: 'Possible Errors',
14
+ recommended: true,
15
+ url: 'https://docs.cypress.io/guides/core-concepts/retry-ability#Actions-should-be-at-the-end-of-chains-not-the-middle',
16
+ },
17
+ schema: [],
18
+ messages: {
19
+ 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.',
21
+ },
22
+ },
23
+ create(context) {
24
+ return {
25
+ CallExpression(node) {
26
+ if (
27
+ isRootCypress(node) &&
28
+ isActionUnsafeToChain(node) &&
29
+ node.parent.type === 'MemberExpression'
30
+ ) {
31
+ context.report({ node, messageId: 'unexpected' });
32
+ }
33
+ },
34
+ };
35
+ },
36
+ };
37
+
38
+ function isRootCypress(node) {
39
+ while (node.type === 'CallExpression') {
40
+ if (node.callee.type !== 'MemberExpression') {
41
+ return false;
42
+ }
43
+
44
+ if (
45
+ node.callee.object.type === 'Identifier' &&
46
+ node.callee.object.name === 'cy'
47
+ ) {
48
+ return true;
49
+ }
50
+
51
+ // eslint-disable-next-line no-param-reassign
52
+ node = node.callee.object;
53
+ }
54
+
55
+ return false;
56
+ }
57
+
58
+ function isActionUnsafeToChain(node) {
59
+ // commands listed in the documentation with text: 'It is unsafe to chain further commands that rely on the subject after xxx'
60
+ const unsafeToChainActions = [
61
+ 'blur',
62
+ 'clear',
63
+ 'click',
64
+ 'check',
65
+ 'dblclick',
66
+ 'each',
67
+ 'focus',
68
+ 'rightclick',
69
+ 'screenshot',
70
+ 'scrollIntoView',
71
+ 'scrollTo',
72
+ 'select',
73
+ 'selectFile',
74
+ 'spread',
75
+ 'submit',
76
+ 'type',
77
+ 'trigger',
78
+ 'uncheck',
79
+ 'within',
80
+ ];
81
+
82
+ return (
83
+ node.callee &&
84
+ node.callee.property &&
85
+ node.callee.property.type === 'Identifier' &&
86
+ unsafeToChainActions.includes(node.callee.property.name)
87
+ );
88
+ }