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 more string methods to prefer-lodash-method rule #136

Closed
skratchdot opened this issue Mar 15, 2017 · 7 comments
Closed

Add more string methods to prefer-lodash-method rule #136

skratchdot opened this issue Mar 15, 2017 · 7 comments

Comments

@skratchdot
Copy link
Contributor

Currently, the following string methods are added to the prefer-lodash-method rule:

  • endsWith
  • includes
  • padEnd
  • padStart
  • startsWith

A few seem to be missing:

  • repeat
  • replace
  • split
  • toLowerCase (toLower)
  • toUpperCase (toUpper)
  • trim
  • trimStart (stage2 only?)
  • trimEnd (stage2 only?)
skratchdot added a commit to skratchdot/eslint-plugin-lodash that referenced this issue Mar 15, 2017
…incubator#136.

The following string methods are now reported on:
- repeat
- replace
- split
- toLowerCase (toLower)
- toUpperCase (toUpper)
- trim
@ganimomer
Copy link
Contributor

Good point! I see you're working on a PR. Thanks!

@skratchdot
Copy link
Contributor Author

I didn't add trimStart and trimEnd since they aren't "official" yet, but now that I think about it, if someone is using str.trimStart(), they should probably be using the lodash method instead.

Another thing I questioned: this rule is pretty complex at the moment. I think it'd be nice to split things out into prefer-endsWith, prefer-some, etc, but that's a bigger / breaking change- so not sure of your thoughts on that.

Thanks for this plugin though! I'm going to find it useful.

@ganimomer
Copy link
Contributor

You're right, it is getting a bit unwieldy. But I think maybe splitting for individual methods could be too much. Maybe categories? (e.g. prefer-lodash-collection-method, prefer-lodash-string-method etc)
What do you think?

skratchdot added a commit to skratchdot/eslint-plugin-lodash that referenced this issue Mar 15, 2017
…incubator#136.

The following string methods are now reported on:
- repeat
- replace
- split
- toLowerCase (toLower)
- toUpperCase (toUpper)
- trim
@ganimomer
Copy link
Contributor

Published in v2.3.6.

@skratchdot
Copy link
Contributor Author

I like that idea better I think. At the same time, it's probably not worth the work/risk in a big refactor. The only reason I mentioned it, is because this is the rule that caused the most errors in our codebase, so I had to disable it temporarily. Once I fix all the errors, it won't be a big deal.

So I just threw the idea out there. Your suggestion is definitely better than the "method-level" rules.

@skratchdot
Copy link
Contributor Author

Thanks!!!

@ganimomer
Copy link
Contributor

Okay, so I'll open an issue for it, but it means a new major version because it's a breaking change, so it'll be a while.

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

2 participants