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

Let scope in for...of loop might be screwy? #2756

Closed
marcoscaceres opened this issue Nov 12, 2015 · 4 comments
Closed

Let scope in for...of loop might be screwy? #2756

marcoscaceres opened this issue Nov 12, 2015 · 4 comments

Comments

@marcoscaceres
Copy link

I have the following, and jshint is complaining that "'name' is defined but never used." in the for of loop.

If I switch from let to var, it works ok tho.

function trimRedundantProps(obj) {
  let defaultProps = Object.getOwnPropertyNames(defaultLocale);
  let redudantProps = [];
  for (let name of Object.getOwnPropertyNames(obj)) {
    if (defaultProps.indexOf(name) === -1) {
      redudantProps.push(name);
      delete obj[name];
    }
  }
  if (redudantProps.length) {
    let msg = `${warn("WARNING:")} Redundant props in ${this.locale}:`; // jshint ignore:line
    msg += notice(`
 * ${redudantProps.join("\n * ")}`);
    console.warn(msg);
  }
  return obj;
}
@nicolo-ribaudo
Copy link
Contributor

Which version of JSHint are you using? I can't reproduce this issue using v2.8.0

@marcoscaceres
Copy link
Author

v2.8.0 also.

If it helps, here is the complete file:
https://raw.githubusercontent.com/mozilla/remote-newtab/l10nStringGetter/bin/fetchl10nstrings.js

@nicolo-ribaudo
Copy link
Contributor

I copied and pasted that file on jshint.com (which uses JSHint 2.8.0), added // jshint unused: true and replaced for (var name of Object.getOwnPropertyNames(obj)) { with for (let name of Object.getOwnPropertyNames(obj)) {, but I still am not able to reproduce the issue.

@marcoscaceres
Copy link
Author

Seems to have fixed itself for me too :/

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

3 participants