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

Update: improve suggestion testing experience #12602

Merged
merged 1 commit into from Dec 20, 2019
Merged

Update: improve suggestion testing experience #12602

merged 1 commit into from Dec 20, 2019

Conversation

bradzacher
Copy link
Contributor

Previously you had to explicitly set suggestions: undefined, or omit the property.
I hate writing undefined in my code, but I also prefer to be explicit in my tests, and explicitly say "I expect no suggestions".

This just lets a user pass any falsey value, or an empty array.
The rule tester will interpret any of these values as "I expect no suggestions".

I.e. these will now be equivalent:

ruleTester.run("suggestions-basic", rule, {
  valid: [],
  invalid: [
    // previously only allowed:
    {},
    {
      suggestions: undefined,
    },
    // now also allows
    {
      suggestions: [],
    },
    {
      suggestions: null,
    },
    {
      suggestions: false,
    },
  ],
});

Previously you had to explicitly pass the exact same value (undefined), which meant either explicitly set `suggestions: undefined`, or omit the property.
I hate writing `undefined`, but I prefer to be explicit in my tests and say "I expect no suggestions".
Now you can pass any falsey, or an empty array, and the rule tester will perform as expected.
@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Nov 25, 2019
@kaicataldo kaicataldo added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Nov 25, 2019
@kaicataldo kaicataldo self-assigned this Nov 25, 2019
@kaicataldo
Copy link
Member

This seems like a good idea to me. I'll champion this.

@ilyavolodin ilyavolodin added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Nov 27, 2019
@platinumazure
Copy link
Member

Note to merger: This should be an "Update:" as we are regarding this as an enhancement.

@kaicataldo kaicataldo changed the title Fix: improve suggestion testing experience Update: improve suggestion testing experience Dec 20, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 19, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 19, 2020
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 enhancement This change enhances an existing feature of ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants