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

Contradictions in no-unneeded-ternary documentation #10872

Closed
CoffeeTableEspresso opened this issue Sep 19, 2018 · 2 comments
Closed

Contradictions in no-unneeded-ternary documentation #10872

CoffeeTableEspresso opened this issue Sep 19, 2018 · 2 comments
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 documentation Relates to ESLint's documentation rule Relates to ESLint's core rules

Comments

@CoffeeTableEspresso
Copy link
Contributor

I'm not sure if this is the right place to raise this issue, but the documentation for the no-unneeded-ternary rule seems to have a mistake.

At one point, it mentions that a || should be used when the middle operand of the ternary is the same as the first:

// Bad
var foo = bar ? bar : 1;

// Good
var foo = bar || 1;

Later, however, it lists something seemingly identical to this as an example of correct code:

var a = x ? x : 1;

In my project, I was given a no-unneeded-ternary error for using this type of code, so the documentation seems to have an error. Either way, the documentation seems to list this sort of construct as both correct and incorrect, so one of those is probably in error.

@CoffeeTableEspresso
Copy link
Contributor Author

I've made a PR here, if this is an error. #10874

@platinumazure
Copy link
Member

Hi @CoffeeTableEspresso, thanks for the issue.

I've left a comment in the PR explaining what's going on. Fundamentally, the documentation is "accurate" but definitely unclear. I think we could improve the docs, but the PR you've submitted isn't quite what we need.

Thanks for raising this issue!

@platinumazure platinumazure added rule Relates to ESLint's core rules documentation Relates to ESLint's documentation accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Sep 20, 2018
platinumazure pushed a commit that referenced this issue Sep 21, 2018
…les (#10874)

* Contradictions in no-unneeded-ternary documentation

See #10872

* Updated examples to more clearly reflect eslint behaviour.

* Update no-unneeded-ternary.md
ch1ller0 pushed a commit to ch1ller0/eslint that referenced this issue Sep 21, 2018
…les (eslint#10874)

* Contradictions in no-unneeded-ternary documentation

See eslint#10872

* Updated examples to more clearly reflect eslint behaviour.

* Update no-unneeded-ternary.md
ch1ller0 pushed a commit to ch1ller0/eslint that referenced this issue Sep 21, 2018
…les (eslint#10874)

* Contradictions in no-unneeded-ternary documentation

See eslint#10872

* Updated examples to more clearly reflect eslint behaviour.

* Update no-unneeded-ternary.md
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 21, 2019
@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 Mar 21, 2019
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 documentation Relates to ESLint's documentation rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

2 participants