Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to unsafe-to-chain-command rule to allow custom Cypress command linting #137

Merged
merged 3 commits into from Aug 8, 2023

Conversation

passbyval
Copy link
Contributor

@passbyval passbyval commented Aug 7, 2023

Context

I was recently using Cypress Real Events in one of my projects, and I realized that the unsafe-to-chain-command rule wasn't triggering errors when using the library's custom Cypress functions. I thought it would be nice to have the ability to pass in additional methods to lint for when using this rule.

Summary

  • Added methods option to allow for linting on custom Cypress commands
    • Takes in either a string or regex
  • Refactored isRootCypress to use recursion instead of a while loop + mutation
  • Added types via JSDoc TypeScript syntax
  • Added appropriate test cases
  • Utilized JSON Schema via ESLint's custom rule API

Usage

Users can now pass in methods to the rule like so:

"cypress/unsafe-to-chain-command": [
  "error",
  {
    "methods": [
      "realClick",
      /customHover/
    ]
  }
]

@CLAassistant
Copy link

CLAassistant commented Aug 7, 2023

CLA assistant check
All committers have signed the CLA.

@cypress-app-bot
Copy link

@passbyval passbyval changed the title Add option to unsafe-to-chain-command rule to allow for custom function names Add option to unsafe-to-chain-command rule to allow linting when using custom Cypress commands Aug 7, 2023
@passbyval passbyval changed the title Add option to unsafe-to-chain-command rule to allow linting when using custom Cypress commands Add method option to unsafe-to-chain-command rule to allow linting when using custom Cypress commands Aug 7, 2023
@passbyval passbyval changed the title Add method option to unsafe-to-chain-command rule to allow linting when using custom Cypress commands feat: add option to unsafe-to-chain-command rule to allow custom Cypress command linting Aug 7, 2023
@nagash77 nagash77 self-assigned this Aug 7, 2023
@jordanpowell88 jordanpowell88 merged commit b9f7a26 into cypress-io:master Aug 8, 2023
7 checks passed
@nagash77
Copy link
Contributor

nagash77 commented Aug 8, 2023

🎉 This PR is included in version 2.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants