Skip to content

Add new "no element handle" rule #40

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

Merged

Conversation

elaichenkov
Copy link
Contributor

Adds new no-element-handle rule.

Description:
This rule disallows using the page.$ element handle and page.$$ element handles. Because the use of ElementHandle is discouraged, use Locator instead. Besides, it can convert an element handle to a locator.

@elaichenkov elaichenkov changed the title No element handle rule Add new "no element handle" rule Apr 10, 2022
@elaichenkov elaichenkov requested a review from mskelton April 11, 2022 13:37
@elaichenkov
Copy link
Contributor Author

elaichenkov commented Apr 11, 2022

@mskelton when you get a chance please take a look at PR once again. I've updated it.

@mxschmitt
Copy link
Collaborator

Maybe we should also discourage from $eval and $$eval?

@elaichenkov
Copy link
Contributor Author

Maybe we should also discourage from $eval and $$eval?

Yeah, sure. However, I'd create a new no-eval-method or no-eval rule for it, which would prevent usage of page.$eval and page.$$eval. How do you feel about this?

@elaichenkov elaichenkov requested a review from mskelton April 11, 2022 14:52
Copy link
Member

@mskelton mskelton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@elaichenkov
Copy link
Contributor Author

Great work!

Thank you! Btw, I'd love to start working on the "page.$eval and page.$$eval" rule. What do you think is a better name for this?

  1. no-eval-method
  2. no-eval-function
  3. no-eval

@mskelton mskelton merged commit 0ec8932 into playwright-community:master Apr 11, 2022
@mskelton
Copy link
Member

no-eval seems fine with me. It's scoped to this package, so it would be playwright/no-eval so there isn't an issue with it conflicting with the built-in no-eval rule.

@mskelton
Copy link
Member

Alternatively, it could be no-page-eval similar to no-page-pause 🤷‍♂️

@mxschmitt mxschmitt mentioned this pull request Apr 28, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants