Git Product home page Git Product logo

Comments (14)

pmcelhaney avatar pmcelhaney commented on May 27, 2024 2

Yeah, I can see how people might want to slice "compatibility" different ways:

  1. As long as I can swap out the _ function with the native function and know my code won't break, I'm happy. I'm not concerned about sparse arrays because I don't use them (at least not intentionally).
  2. I don't consider the native and _ to be compatible unless they behave exactly the same way for all inputs (including edge cases such as sparse arrays).
  3. I don't want to swap the _ function with the native function unless I know I have nothing to lose by doing so. If the _ is more efficient (because it doesn't deal with edge cases like sparse arrays), I want to keep it.

Personally, I favor #1. If you and @cht8687 agree, maybe we just run with that. At least for now. We can always come back and add more fields to the JSON file to denote the ramifications of switching from _ to native.

from you-dont-need-lodash-underscore.

stevemao avatar stevemao commented on May 27, 2024 2

For a future smarter version, the linter should error/warn on _.forEach(array) but not _.forEach(object) (at least show a different message) etc.

from you-dont-need-lodash-underscore.

pmcelhaney avatar pmcelhaney commented on May 27, 2024 1

BTW, the settings for the "compatible" flag at the moment may not strictly match any of these definitions. We need to review each rule carefully with respect to whether the native function is truly compatible with the _ function.

On Jul 2, 2016, at 8:47 PM, Steve Mao [email protected] wrote:

rules in which the native implementation exactly matches the _ one

I think this could mean two things:

  1. signature of the function is exactly the same but the implementation might be different
  2. _ uses the native method

I tend to favour the first definition here for this module.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

from you-dont-need-lodash-underscore.

pmcelhaney avatar pmcelhaney commented on May 27, 2024 1

I've given it some more though and opened #57 and #58. Before we set any default configs, it makes sense to flesh out the options of the individual rules. There's an opportunity to add more nuance than simply which rules are warnings and which are errors.

from you-dont-need-lodash-underscore.

cht8687 avatar cht8687 commented on May 27, 2024

sounds a good idea Pat. @stevemao thoughts?

from you-dont-need-lodash-underscore.

stevemao avatar stevemao commented on May 27, 2024

Good idea!

from you-dont-need-lodash-underscore.

stevemao avatar stevemao commented on May 27, 2024

Maybe another config to error on rules in which the native implementation exactly matches the _ ones but warn on rules that could be replaced by native?

from you-dont-need-lodash-underscore.

stevemao avatar stevemao commented on May 27, 2024

rules in which the native implementation exactly matches the _ one

I think this could mean two things:

  1. signature of the function is exactly the same but the implementation might be different
  2. _ uses the native method

I tend to favour the first definition here for this module.

from you-dont-need-lodash-underscore.

pmcelhaney avatar pmcelhaney commented on May 27, 2024

Yes, if I understand correctly, that's what I would probably want as a default. Error if I know I can replace the _ function with a native function that works the same way. Warn if I may or may be able to switch to native depending on the use case.

That's the config I called safe-strict. I'm not crazy about that particular name. If we put our heads together I bet we can come up a useful set of config options and a more intuitive naming scheme.

On Jul 2, 2016, at 8:28 PM, Steve Mao [email protected] wrote:

Maybe another config to error on rules in which the native implementation exactly matches the _ ones but warn on rules that could be replaced by native?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

from you-dont-need-lodash-underscore.

pmcelhaney avatar pmcelhaney commented on May 27, 2024

I would say if the contracts match. For any given input the _ and native functions will produce the same output. I think that's what you meant by signature but want to be sure.

On Jul 2, 2016, at 8:47 PM, Steve Mao [email protected] wrote:

rules in which the native implementation exactly matches the _ one

I think this could mean two things:

  1. signature of the function is exactly the same but the implementation might be different
  2. _ uses the native method

I tend to favour the first definition here for this module.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

from you-dont-need-lodash-underscore.

stevemao avatar stevemao commented on May 27, 2024

signature I mean the type of the parameters and return value are exactly the same. And it does exactly the same thing as the native method. The internal implementation/performance might be different.
A lot of array methods are not. EG: because _ uses a stripped-down version of loop so it gains performance but doesn't work with sparse arrays.

from you-dont-need-lodash-underscore.

stevemao avatar stevemao commented on May 27, 2024

That's the config I called safe-strict.

Sorry yes, I misread your comment.

from you-dont-need-lodash-underscore.

mockdeep avatar mockdeep commented on May 27, 2024

Would love to have an all that defaults to error and any reasonable default config. This is similar to eslint:all and plugin:react/all. I'm happy to selectively disable or configure things myself.

from you-dont-need-lodash-underscore.

Vadorequest avatar Vadorequest commented on May 27, 2024

Really good idea, I just found out about this repo and I was wondering how to setup all rules to errors in a simple way.

from you-dont-need-lodash-underscore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.