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 rule: prefer-simple-object-enumeration #23

Open
sbdchd opened this issue Jun 24, 2021 · 0 comments
Open

new rule: prefer-simple-object-enumeration #23

sbdchd opened this issue Jun 24, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@sbdchd
Copy link
Owner

sbdchd commented Jun 24, 2021

// err
for (const key of Object.keys(mapping)) {
  const value = mapping[key];
  // ...
}
for (const key of Object.keys(mapping) as (keyof MappingType)[]) {
  const value = mapping[key];
  // ...
}

// ok
for (const value of Object.values(mapping)) {
  // ...
}

I think we need to check if someone ids calling Object.keys() and then indexing into the variable they called Object.keys() on. Also need to check that they don't use key later in the block

similar: sbdchd/flake8-pie#87

@sbdchd sbdchd changed the title new rule: prefer-object-values new rule: prefer-simple-object-method Jun 24, 2021
@sbdchd sbdchd added the enhancement New feature or request label Jun 26, 2021
@sbdchd sbdchd changed the title new rule: prefer-simple-object-method new rule: prefer-simple-object-enumeration Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant