eslint-config-seek 0.0.0-cypress-fork-20230524064546 → 0.0.0-fix-curly-braces-20231115033054
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 +17 -7
- package/index.js +25 -1
- package/package.json +18 -18
- package/{eslint-local-rules → rules}/unsafe-to-chain-command.js +12 -4
- package/eslint-local-rules/index.js +0 -3
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 = path.join(__dirname, 'rules');
|
|
9
|
+
|
|
7
10
|
const baseRules = {
|
|
8
11
|
// Possible Errors
|
|
9
12
|
'no-console': ERROR,
|
|
@@ -107,13 +110,16 @@ const baseConfig = {
|
|
|
107
110
|
files: [`**/*.{${tsExtensions}}`],
|
|
108
111
|
parser: '@typescript-eslint/parser',
|
|
109
112
|
parserOptions: {
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/6544
|
|
114
|
+
allowAutomaticSingleRunInference: true,
|
|
115
|
+
ecmaVersion: 2022,
|
|
112
116
|
project: true,
|
|
117
|
+
sourceType: 'module',
|
|
118
|
+
warnOnUnsupportedTypeScriptVersion: false,
|
|
113
119
|
},
|
|
114
120
|
extends: [
|
|
115
|
-
'plugin:@typescript-eslint/eslint-recommended',
|
|
116
121
|
'plugin:@typescript-eslint/recommended',
|
|
122
|
+
'plugin:@typescript-eslint/stylistic',
|
|
117
123
|
'prettier',
|
|
118
124
|
],
|
|
119
125
|
settings: {
|
|
@@ -124,6 +130,7 @@ const baseConfig = {
|
|
|
124
130
|
},
|
|
125
131
|
},
|
|
126
132
|
rules: {
|
|
133
|
+
'@typescript-eslint/array-type': [ERROR, { default: 'array-simple' }],
|
|
127
134
|
'@typescript-eslint/no-unused-expressions': ERROR,
|
|
128
135
|
'@typescript-eslint/no-unused-vars': [
|
|
129
136
|
ERROR,
|
|
@@ -180,7 +187,7 @@ const baseConfig = {
|
|
|
180
187
|
settings: {
|
|
181
188
|
'import/resolver': {
|
|
182
189
|
node: {
|
|
183
|
-
moduleDirectory: [root,
|
|
190
|
+
moduleDirectory: [root, 'node_modules'],
|
|
184
191
|
},
|
|
185
192
|
},
|
|
186
193
|
},
|
|
@@ -210,13 +217,16 @@ const baseConfig = {
|
|
|
210
217
|
{
|
|
211
218
|
// Cypress config
|
|
212
219
|
files: [`**/cypress/**/*.{${allExtensions}}`],
|
|
220
|
+
// eslint-plugin-cypress doesn't support ESLint v8.
|
|
221
|
+
// Use fork by `@finsit` until this is solved.
|
|
222
|
+
// https://github.com/cypress-io/eslint-plugin-cypress/issues/89
|
|
223
|
+
extends: ['plugin:@finsit/cypress/recommended'],
|
|
213
224
|
env: {
|
|
214
225
|
'@finsit/cypress/globals': true,
|
|
215
226
|
},
|
|
216
|
-
|
|
217
|
-
plugins: ['@finsit/cypress', 'eslint-plugin-local-rules'],
|
|
227
|
+
plugins: ['@finsit/cypress', 'rulesdir'],
|
|
218
228
|
rules: {
|
|
219
|
-
'
|
|
229
|
+
'rulesdir/unsafe-to-chain-command': ERROR,
|
|
220
230
|
},
|
|
221
231
|
},
|
|
222
232
|
],
|
package/index.js
CHANGED
|
@@ -10,6 +10,10 @@ const reactRules = {
|
|
|
10
10
|
'react/no-children-prop': ERROR,
|
|
11
11
|
'react/display-name': OFF,
|
|
12
12
|
'react/prop-types': OFF,
|
|
13
|
+
'react/jsx-curly-brace-presence': [
|
|
14
|
+
ERROR,
|
|
15
|
+
{ props: 'never', children: 'ignore', propElementValues: 'always' },
|
|
16
|
+
],
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
/** @type {import('eslint').Linter.Config} */
|
|
@@ -23,7 +27,11 @@ const eslintConfig = {
|
|
|
23
27
|
},
|
|
24
28
|
},
|
|
25
29
|
plugins: ['react', 'react-hooks'],
|
|
26
|
-
extends: [
|
|
30
|
+
extends: [
|
|
31
|
+
'plugin:react/recommended',
|
|
32
|
+
'plugin:react/jsx-runtime',
|
|
33
|
+
'./base.js',
|
|
34
|
+
],
|
|
27
35
|
parserOptions: {
|
|
28
36
|
babelOptions: {
|
|
29
37
|
presets: [require.resolve('@babel/preset-react')],
|
|
@@ -32,6 +40,22 @@ const eslintConfig = {
|
|
|
32
40
|
rules: {
|
|
33
41
|
...reactRules,
|
|
34
42
|
},
|
|
43
|
+
overrides: [
|
|
44
|
+
{
|
|
45
|
+
// temporary override until everybody removes the React import
|
|
46
|
+
files: [`**/*.tsx`],
|
|
47
|
+
rules: {
|
|
48
|
+
'@typescript-eslint/no-unused-vars': [
|
|
49
|
+
ERROR,
|
|
50
|
+
{
|
|
51
|
+
argsIgnorePattern: '^_',
|
|
52
|
+
ignoreRestSiblings: true,
|
|
53
|
+
varsIgnorePattern: '^React$',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
35
59
|
};
|
|
36
60
|
|
|
37
61
|
module.exports = eslintConfig;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-seek",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-fix-curly-braces-20231115033054",
|
|
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
|
-
"
|
|
10
|
+
"rules/*"
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -20,39 +20,39 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/seek-oss/eslint-config-seek#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.
|
|
24
|
-
"@babel/eslint-parser": "^7.
|
|
25
|
-
"@babel/preset-react": "^7.
|
|
23
|
+
"@babel/core": "^7.22.6",
|
|
24
|
+
"@babel/eslint-parser": "^7.22.6",
|
|
25
|
+
"@babel/preset-react": "^7.22.5",
|
|
26
26
|
"@finsit/eslint-plugin-cypress": "^3.1.1",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
28
|
-
"@typescript-eslint/parser": "^
|
|
29
|
-
"eslint-config-prettier": "^8.
|
|
30
|
-
"eslint-import-resolver-typescript": "3.5.
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
28
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
29
|
+
"eslint-config-prettier": "^8.8.0",
|
|
30
|
+
"eslint-import-resolver-typescript": "3.5.5",
|
|
31
31
|
"eslint-plugin-import": "^2.27.5",
|
|
32
|
-
"eslint-plugin-jest": "^27.2.
|
|
33
|
-
"eslint-plugin-local-rules": "^1.3.2",
|
|
32
|
+
"eslint-plugin-jest": "^27.2.3",
|
|
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": {
|
|
39
|
-
"@changesets/cli": "^2.26.
|
|
39
|
+
"@changesets/cli": "^2.26.2",
|
|
40
40
|
"@changesets/get-github-info": "^0.5.2",
|
|
41
|
-
"eslint": "^8.
|
|
41
|
+
"eslint": "^8.44.0",
|
|
42
42
|
"prettier": "^2.8.4",
|
|
43
|
-
"typescript": "~
|
|
43
|
+
"typescript": "~5.1.6"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"eslint": ">=
|
|
46
|
+
"eslint": ">=7",
|
|
47
47
|
"typescript": ">=4.5"
|
|
48
48
|
},
|
|
49
|
-
"packageManager": "pnpm@8.
|
|
49
|
+
"packageManager": "pnpm@8.6.6",
|
|
50
50
|
"volta": {
|
|
51
|
-
"node": "
|
|
51
|
+
"node": "18.12.1"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"release": "changeset publish",
|
|
55
|
-
"test": "eslint
|
|
55
|
+
"test": "eslint . && eslint --config base.js .",
|
|
56
56
|
"changeset-version": "changeset version && prettier --write ."
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** This rule
|
|
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
|
|
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
|
|
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,17 @@ module.exports = {
|
|
|
28
31
|
isActionUnsafeToChain(node) &&
|
|
29
32
|
node.parent.type === 'MemberExpression'
|
|
30
33
|
) {
|
|
31
|
-
context.report({
|
|
34
|
+
context.report({
|
|
35
|
+
node,
|
|
36
|
+
messageId: 'unexpected',
|
|
37
|
+
});
|
|
32
38
|
}
|
|
33
39
|
},
|
|
34
40
|
};
|
|
35
41
|
},
|
|
36
42
|
};
|
|
37
43
|
|
|
44
|
+
/** @param {import("eslint").Rule.Node} node */
|
|
38
45
|
function isRootCypress(node) {
|
|
39
46
|
while (node.type === 'CallExpression') {
|
|
40
47
|
if (node.callee.type !== 'MemberExpression') {
|
|
@@ -55,6 +62,7 @@ function isRootCypress(node) {
|
|
|
55
62
|
return false;
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
/** @param {import("eslint").Rule.Node} node */
|
|
58
66
|
function isActionUnsafeToChain(node) {
|
|
59
67
|
// commands listed in the documentation with text: 'It is unsafe to chain further commands that rely on the subject after xxx'
|
|
60
68
|
const unsafeToChainActions = [
|