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

Add a rule to prevent the use of labels #550

Closed
DavidBruant opened this issue Jan 20, 2014 · 3 comments
Closed

Add a rule to prevent the use of labels #550

DavidBruant opened this issue Jan 20, 2014 · 3 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@DavidBruant
Copy link
Contributor

They're usually a bad practice.

Maybe related, I'm not sure I fully understand no-empty-label. I need to read more about it.

@nzakas
Copy link
Member

nzakas commented Jan 20, 2014

Happy to consider it. Do you have more details as to why this is a bad practice? (We like to include narrative in the docs for each rule)

@DavidBruant
Copy link
Contributor Author

Pretty much all concerns about GOTO apply to labels.
We got rid of GOTO by adding higher-level primitives like while loops, if/else, switch statements and function calls which cover the vast majority of GOTO use cases. These constructs make code easier to read/review/refactor than code using labels.

I don't hold any sort of proof, but given the sort of flexibility they provide, it's possible the use of labels locally disables some optimizations of current JS engines. At the very least, the fact that they're rarely used and absent from popular benchmarks makes them unlikely target for JS engine engineers to optimize for.

@nzakas
Copy link
Member

nzakas commented Feb 2, 2014

Working on this.

@nzakas nzakas closed this as completed in ba40035 Feb 2, 2014
nzakas added a commit that referenced this issue Feb 2, 2014
New Rule: no-labels (fixes #550)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@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 Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

2 participants