Code Monkey home page Code Monkey logo

Comments (10)

gajus avatar gajus commented on May 28, 2024

I cannot think of how to fix this at the AST level.

from eslint-plugin-lodash.

ganimomer avatar ganimomer commented on May 28, 2024

Neither can we. At the AST level, there's no way of knowing that $(movieElement).parents('h3').siblings('.show_results') isn't an array, and this plugin should be library agnostic, except for Lodash itself.
I guess I would advise to turn off this rule for corresponding lines, files, or folders in general.

from eslint-plugin-lodash.

gajus avatar gajus commented on May 28, 2024

Technically, you could add a check if the top-most node in the chain is $() declaration.

99% of the code that relies on jQuery like DOM iterators use this convention.

from eslint-plugin-lodash.

gajus avatar gajus commented on May 28, 2024

It gets a bit harder if you do something like this:

$(movieElement)
    .parents('h3')
    .siblings('.show_results')
    .find('.film_time_listing span a')
    [0]
    .find(conditionFn)

Though thats an edge use-case.

from eslint-plugin-lodash.

ganimomer avatar ganimomer commented on May 28, 2024

Yes, technically we could. However, Like I said, the plugin doesn't assume anything about variables by their names except for Lodash. There could technically be a $() definition in which the find is the native ES6 Array.prototype.find.
In general, we have no way of knowing that any method that's named like an array method isn't used on an array.
Again, in this case I think you should disable this specific rule.

from eslint-plugin-lodash.

gajus avatar gajus commented on May 28, 2024

There is no way to disable it just for "find" and otherwise this is the only rule that I find useful.

On Nov 25, 2015, at 16:38, Omer Ganim [email protected] wrote:

Yes, technically we could. However, Like I said, the plugin doesn't assume anything about variables by their names except for Lodash. There could technically be a $() definition in which the find is the native ES6 Array.prototype.find.
In general, we have no way of knowing that any method that's named like an array method isn't used on an array.
Again, in this case I think you should disable this specific rule.

β€”
Reply to this email directly or view it on GitHub.

from eslint-plugin-lodash.

gajus avatar gajus commented on May 28, 2024

This also breaks when using http://bluebirdjs.com/docs/api-reference.html. There is no obvious solution. Shame, in theory it is a nice linting rule. In practise it is just not functional.

from eslint-plugin-lodash.

gajus avatar gajus commented on May 28, 2024

I wonder how feasible would it be to define something like this in a run-time setup.

from eslint-plugin-lodash.

mik01aj avatar mik01aj commented on May 28, 2024

πŸ‘ +1 for adding configuration to this rule so that we can disable it just for find.

from eslint-plugin-lodash.

gajus avatar gajus commented on May 28, 2024

For the record, I never suggested to disable this rule just for find and I think thats a bad idea.

from eslint-plugin-lodash.

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.