eslint-plugin-cypress 2.11.1 → 2.11.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/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install eslint-plugin-cypress --save-dev
|
|
|
11
11
|
```
|
|
12
12
|
or
|
|
13
13
|
```sh
|
|
14
|
-
yarn add eslint-plugin-cypress --
|
|
14
|
+
yarn add eslint-plugin-cypress --dev
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
@@ -40,7 +40,7 @@ You can add rules:
|
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
You can
|
|
43
|
+
You can allow certain globals provided by Cypress:
|
|
44
44
|
|
|
45
45
|
```json
|
|
46
46
|
{
|
|
@@ -39,7 +39,7 @@ module.exports = {
|
|
|
39
39
|
},
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const allowedCommands = {
|
|
43
43
|
now: true,
|
|
44
44
|
spy: true,
|
|
45
45
|
state: true,
|
|
@@ -61,7 +61,7 @@ function isCypressCommandDeclaration (declarator) {
|
|
|
61
61
|
|
|
62
62
|
const parent = get(object, 'parent.property.name') || get(declarator, 'id.name')
|
|
63
63
|
|
|
64
|
-
if (commandName && (
|
|
64
|
+
if (commandName && (allowedCommands[commandName] || allowedCommands[parent])) return
|
|
65
65
|
|
|
66
66
|
return object.name === 'cy'
|
|
67
67
|
}
|
|
@@ -56,7 +56,8 @@ function isIdentifierNumberConstArgument (node, scope) {
|
|
|
56
56
|
|
|
57
57
|
if (node.arguments[0].type !== 'Identifier') return false
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const identifier = node.arguments[0]
|
|
60
|
+
const resolvedIdentifier = scope.references.find((ref) => ref.identifier === identifier).resolved
|
|
60
61
|
const definition = resolvedIdentifier.defs[0]
|
|
61
62
|
const isVariable = definition.type === 'Variable'
|
|
62
63
|
|