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

New: Add only to RuleTester (refs eslint/rfcs#73) #14677

Merged
merged 5 commits into from Jun 18, 2021
Merged

New: Add only to RuleTester (refs eslint/rfcs#73) #14677

merged 5 commits into from Jun 18, 2021

Conversation

btmills
Copy link
Member

@btmills btmills commented Jun 6, 2021

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

This implements RFC73. RuleTester test cases support a new only property to run an individual case or subset of cases for less noisy debugging. We do not implement test exclusivity inside RuleTester, instead relying on the test framework to provide that functionality when we call only().

Is there anything you'd like reviewers to focus on?

  1. I made one change from the RFC. Under Detailed Design, step 3, I inserted a new sub-step between i and ii: "If RuleTester[IT] is set and has an only function property, return Function.bind.call(this[IT].only, this[IT])." For users who customize RuleTester.it, this could make only work without any additional configuration, but if their overridden it has an only function property with different semanticts than Mocha's, this step wouldn't work. Are we okay with this change?
  2. Because the RuleTester tests override RuleTester.it and RuleTester.only, testing the itOnly getter was complex.

@btmills btmills added core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion feature This change adds a new feature to ESLint labels Jun 6, 2021
@mdjermanovic
Copy link
Member

  1. I made one change from the RFC. Under Detailed Design, step 3, I inserted a new sub-step between i and ii: "If RuleTester[IT] is set and has an only function property, return Function.bind.call(this[IT].only, this[IT])." For users who customize RuleTester.it, this could make only work without any additional configuration, but if their overridden it has an only function property with different semanticts than Mocha's, this step wouldn't work. Are we okay with this change?

Makes sense to me, some customizations might "just work". If it doesn't work by itself, they can override RuleTester.itOnly.

tests/lib/rule-tester/rule-tester.js Outdated Show resolved Hide resolved
tests/lib/rule-tester/rule-tester.js Outdated Show resolved Hide resolved
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, great work!

We can revisit the use of this in static accessors later.

btmills and others added 4 commits June 18, 2021 15:43
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Co-authored-by: 薛定谔的猫 <weiran.zsd@outlook.com>
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
@btmills btmills merged commit bfbfe5c into master Jun 18, 2021
@btmills btmills deleted the rfc73 branch June 18, 2021 19:58
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Dec 16, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants