Git Product home page Git Product logo

Comments (5)

AdrienLemaire avatar AdrienLemaire commented on May 28, 2024 1

@javier-garcia-meteologica thank you very much, I was struggling to figure out why coc-eslint was using my system eslint (v7.3.0, currently broken with import/no-cycle) instead of the local one (v7.2, works fine), and adding "eslint.nodePath": "./node_modules", did the trick ❤️

from coc-eslint.

BenoitZugmeyer avatar BenoitZugmeyer commented on May 28, 2024

Sorry to kick in like this, but the proposed fix for this issue is the cause of the issue #77.

With all due respect, I'm not sure to understand the issue (and the commit supposed to fix it).

@javier-garcia-meteologica

The variable directory will resolve to /home/user/project. The function call resolveModule('./eslint', '/home/user/project', undefined) will try to read the non-existing directory '/home/user/project/eslint', which will fail.

This is absolutely true, but then the .catch will be invoked, and resolveModule('eslint', directory, nodePath) should be used as a fallback. This fallback will be in charge of resolving the local or global eslint module to use.

I tried to reproduce the issue you are facing. But with the initial condition you are mentioning (empty configuration, local setup of eslint in /project/node_modules/eslint), coc-eslint (before the proposed fix) is successfully resolving to the local eslint install (as shown in :CocInfo). Did I miss something?

from coc-eslint.

javier-garcia-meteologica avatar javier-garcia-meteologica commented on May 28, 2024

If I use the code

      promise = resolveModule('./eslint', directory, nodePath).catch(() => {
        return resolveModule('eslint', directory, nodePath)
      })

Then it resolves to /home/user/.config/yarn/global/node_modules/eslint/lib/api.js instead of <project>/node_modules/eslint

from coc-eslint.

BenoitZugmeyer avatar BenoitZugmeyer commented on May 28, 2024

Thanks, I understand the issue now! I'll think of something.

from coc-eslint.

javier-garcia-meteologica avatar javier-garcia-meteologica commented on May 28, 2024

I noticed that reversing the priority order makes module resolution work as expected . It picks up <project>/node_modules/eslint first.

      promise = resolveModule('eslint', directory, nodePath).catch(() => {
        return resolveModule('./eslint', directory, nodePath)
      })

@BenoitZugmeyer, could this fix #77?

from coc-eslint.

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.