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

Rule proposal: no-restricted-loops #2453

Open
zanminkian opened this issue Sep 16, 2024 · 1 comment
Open

Rule proposal: no-restricted-loops #2453

zanminkian opened this issue Sep 16, 2024 · 1 comment

Comments

@zanminkian
Copy link
Contributor

Description

JavaScript has 6 kind of loops. We don't really need all of them. Just allow 2 of them (by default) is enough.

Loop Example Allow(by default)
while while(true){}
for-of for(const foo of bar){}
for for(let i=0;i<10;i++){}
for-in for(const foo in bar){}
do-while do{}while(foo<bar)
for-await-of for await (const num of foo()){}

This rule provide an options: restricted-loops, defaults to ['for','for-in','do-while','for-await-of']

Fail

See Description.

Pass

See Description.

Proposed rule name

no-restricted-loops

Additional Info

No response

@zanminkian
Copy link
Contributor Author

no-for-loop can be removed if this rule is implemented. no-for-loop will do auto-fixing. I don't think we need to do auto-fixing in this rule. Auto-fixing make this rule complex to understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant