eslint-config-seek 11.1.1 → 11.1.2
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
|
@@ -210,11 +210,17 @@ const baseConfig = {
|
|
|
210
210
|
{
|
|
211
211
|
// Cypress config
|
|
212
212
|
files: [`**/cypress/**/*.{${allExtensions}}`],
|
|
213
|
+
// eslint-plugin-cypress doesn't support ESLint v8.
|
|
214
|
+
// Use fork by `@finsit` until this is solved.
|
|
215
|
+
// https://github.com/cypress-io/eslint-plugin-cypress/issues/89
|
|
216
|
+
extends: ['plugin:@finsit/cypress/recommended'],
|
|
213
217
|
env: {
|
|
214
|
-
'cypress/globals': true,
|
|
218
|
+
'@finsit/cypress/globals': true,
|
|
219
|
+
},
|
|
220
|
+
plugins: ['@finsit/cypress', 'eslint-plugin-local-rules'],
|
|
221
|
+
rules: {
|
|
222
|
+
'local-rules/unsafe-to-chain-command': ERROR,
|
|
215
223
|
},
|
|
216
|
-
extends: ['plugin:cypress/recommended'],
|
|
217
|
-
plugins: ['cypress'],
|
|
218
224
|
},
|
|
219
225
|
],
|
|
220
226
|
};
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-seek",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.2",
|
|
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
|
-
"extensions.js"
|
|
9
|
+
"extensions.js",
|
|
10
|
+
"eslint-local-rules/*"
|
|
10
11
|
],
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
@@ -22,13 +23,14 @@
|
|
|
22
23
|
"@babel/core": "^7.21.0",
|
|
23
24
|
"@babel/eslint-parser": "^7.19.1",
|
|
24
25
|
"@babel/preset-react": "^7.18.6",
|
|
26
|
+
"@finsit/eslint-plugin-cypress": "^3.1.1",
|
|
25
27
|
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
|
26
28
|
"@typescript-eslint/parser": "^5.53.0",
|
|
27
29
|
"eslint-config-prettier": "^8.6.0",
|
|
28
30
|
"eslint-import-resolver-typescript": "3.5.3",
|
|
29
|
-
"eslint-plugin-cypress": "^2.12.1",
|
|
30
31
|
"eslint-plugin-import": "^2.27.5",
|
|
31
32
|
"eslint-plugin-jest": "^27.2.1",
|
|
33
|
+
"eslint-plugin-local-rules": "^1.3.2",
|
|
32
34
|
"eslint-plugin-react": "^7.32.2",
|
|
33
35
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
34
36
|
"find-root": "^1.1.0"
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
"eslint": ">=6",
|
|
45
47
|
"typescript": ">=4.5"
|
|
46
48
|
},
|
|
47
|
-
"packageManager": "pnpm@
|
|
49
|
+
"packageManager": "pnpm@8.5.1",
|
|
48
50
|
"volta": {
|
|
49
51
|
"node": "16.19.1"
|
|
50
52
|
},
|