sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules
MIT License
4.18k stars 361 forks source link

Configurable callee blacklist for `no-fn-reference-in-iterator` #787

Open gurpreetatwal opened 4 years ago

gurpreetatwal commented 4 years ago

I noticed that the rule currently has a hard-coded blacklist of callees to ignore.

I ran into a bit of an issue with this as we're currently moving our code base off of bluebird (callee: Promise) to async / await + blend-promise-utils (callee: P). That switch from Promise.map to P.map started throwing false-positives all over our codebase.

What are people's thoughts on making this a configurable option? I'd be willing to take a stab at a PR for it if so.

sindresorhus commented 4 years ago

Sure, PR welcome. Although, for common cases, we could also like to add it to the built-in ignore list.

gurpreetatwal commented 4 years ago

Working on the PR for the configurable option now.

Do you think P should be added to the built-in ignore list as well? I'm mostly for that idea, however have two main hesitations:

  1. The callee name of P isn't really standardized the same way that _ is for Lodash. The README for blend-promise-utils actually requires the library as promiseUtils, but my company decided to go with P since we wanted that library to be our "lodash" equivalent for promises. Counter Argument to this point: every "standard" has to start somewhere :stuck_out_tongue_closed_eyes:
  2. The callee name P is quite short and I have a slight fear about it having false "matches" to variable names that people might have already. Counter Argument: Using the name P outside of standardized name is bad naming practice anyway.