eslint-config-seek 0.0.0-cypress-fork-20230524064546 → 0.0.0-rulesdir-20230604234812
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
|
@@ -4,6 +4,9 @@ const root = require('find-root')(process.cwd());
|
|
|
4
4
|
const OFF = 0;
|
|
5
5
|
const ERROR = 2;
|
|
6
6
|
|
|
7
|
+
const rulesDirPlugin = require('eslint-plugin-rulesdir');
|
|
8
|
+
rulesDirPlugin.RULES_DIR = 'rules'; // (an example folder where your rules might be stored)
|
|
9
|
+
|
|
7
10
|
const baseRules = {
|
|
8
11
|
// Possible Errors
|
|
9
12
|
'no-console': ERROR,
|
|
@@ -210,13 +213,16 @@ const baseConfig = {
|
|
|
210
213
|
{
|
|
211
214
|
// Cypress config
|
|
212
215
|
files: [`**/cypress/**/*.{${allExtensions}}`],
|
|
216
|
+
// eslint-plugin-cypress doesn't support ESLint v8.
|
|
217
|
+
// Use fork by `@finsit` until this is solved.
|
|
218
|
+
// https://github.com/cypress-io/eslint-plugin-cypress/issues/89
|
|
219
|
+
extends: ['plugin:@finsit/cypress/recommended'],
|
|
213
220
|
env: {
|
|
214
221
|
'@finsit/cypress/globals': true,
|
|
215
222
|
},
|
|
216
|
-
|
|
217
|
-
plugins: ['@finsit/cypress', 'eslint-plugin-local-rules'],
|
|
223
|
+
plugins: ['@finsit/cypress', 'rulesdir'],
|
|
218
224
|
rules: {
|
|
219
|
-
'
|
|
225
|
+
'rulesdir/unsafe-to-chain-command': ERROR,
|
|
220
226
|
},
|
|
221
227
|
},
|
|
222
228
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-seek",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-rulesdir-20230604234812",
|
|
4
4
|
"description": "ESLint configuration used by SEEK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"eslint-import-resolver-typescript": "3.5.3",
|
|
31
31
|
"eslint-plugin-import": "^2.27.5",
|
|
32
32
|
"eslint-plugin-jest": "^27.2.1",
|
|
33
|
-
"eslint-plugin-local-rules": "^1.3.2",
|
|
34
33
|
"eslint-plugin-react": "^7.32.2",
|
|
35
34
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
35
|
+
"eslint-plugin-rulesdir": "^0.2.2",
|
|
36
36
|
"find-root": "^1.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -1,88 +0,0 @@
|
|
|
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
|
-
}
|