Skip to content

Commit

Permalink
Merge pull request #182 from MikeMcC399/convert-to-sourcecode
Browse files Browse the repository at this point in the history
fix: convert deprecated context calls
  • Loading branch information
jennifer-shehane authored Apr 26, 2024
2 parents 21c8bd2 + 534db69 commit 429ac7f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/rules/no-async-before.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ module.exports = {
&& node.arguments.length >= 2
&& node.arguments[1].async === true
}
const sourceCode = context.sourceCode ?? context.getSourceCode()

return {
Identifier (node) {
if (node.name === 'cy' || node.name === 'Cypress') {
const ancestors = context.getAncestors()
const ancestors = sourceCode.getAncestors
? sourceCode.getAncestors(node)
: context.getAncestors()
const asyncTestBlocks = ancestors
.filter((n) => n.type === 'CallExpression')
.filter(isBeforeBlock)
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/no-async-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ module.exports = {
&& node.arguments.length >= 2
&& node.arguments[1].async === true
}
const sourceCode = context.sourceCode ?? context.getSourceCode()

return {
Identifier (node) {
if (node.name === 'cy' || node.name === 'Cypress') {
const ancestors = context.getAncestors()
const ancestors = sourceCode.getAncestors
? sourceCode.getAncestors(node)
: context.getAncestors()
const asyncTestBlocks = ancestors
.filter((n) => n.type === 'CallExpression')
.filter(isTestBlock)
Expand Down
6 changes: 5 additions & 1 deletion lib/rules/no-unnecessary-waiting.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ module.exports = {
},
},
create (context) {
const sourceCode = context.sourceCode ?? context.getSourceCode()

return {
CallExpression (node) {
if (isCallingCyWait(node)) {
const scope = context.getScope()
const scope = sourceCode.getScope
? sourceCode.getScope(node)
: context.getScope()

if (isIdentifierNumberConstArgument(node, scope) || isNumberArgument(node)) {
context.report({ node, messageId: 'unexpected' })
Expand Down

0 comments on commit 429ac7f

Please sign in to comment.