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

bug: lodash/prefer-constant false positive within class #225

Open
gurpreetatwal opened this issue Dec 26, 2019 · 0 comments
Open

bug: lodash/prefer-constant false positive within class #225

gurpreetatwal opened this issue Dec 26, 2019 · 0 comments

Comments

@gurpreetatwal
Copy link
Contributor

The rule currently warns for methods defined on classes that return constant values, however this isn't the ideal behavior because refactoring those methods to use lodash would produce some weird looking code.

In the following example both methods will be flagged:

class Foo {
  static something() {
    return true;
  }
 
  // other methods 
 
  somethingElse() { 
    return 10;
  }
}

the "fixed" code would look like:

class Foo {
 
  // other methods 
}

Foo.something = _.constant(true);
Foo.prototype.something = _.constant(10);

which isn't ideal

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

No branches or pull requests

1 participant