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

[Linter] Error running ESLint Error: require(...).getLocationFromRangeIndex is not a function(…) #11

Closed
nwaywood opened this issue Mar 23, 2017 · 8 comments

Comments

@nwaywood
Copy link

ESLint is failing to run for me with eslint-plugin-prettier rules activated (i.e. with "rules": { "prettier/prettier": "error" } set).

This is the stacktrace from atom:

image

As it says in the stacktrace, the error comes from this file on line 30 where it calls require('eslint/lib/ast-utils').getLocationFromRangeIndex(...).

Upon inspection of eslint/lib/ast-utils I see that the function no longer exists. The function was removed in this commit.

@not-an-aardvark
Copy link
Member

Does this still occur with eslint-plugin-prettier@2.0.1?

@nwaywood
Copy link
Author

Yes. Here are the devDeps from my package.json

image

@nwaywood
Copy link
Author

nwaywood commented Mar 23, 2017

Not sure if this is important/relevant but this error only happens when the file does not conform to the prettier format. If a file is already formatted by prettier than the linter doesn't log this error

@not-an-aardvark
Copy link
Member

Hmm, that's odd. You're right that the function from eslint/lib/ast-utils no longer exists, but the ternary expression here is intended to check for the existence of sourceCode.getLocFromIndex, which was added in the same commit that the other function was removed.

What version of eslint do you currently have installed? (Your package.json just shows ^3.14.1, but I'm wondering if there's a particular eslint version where this breaks. It seems to work fine for me with the latest version of eslint.)

@nwaywood
Copy link
Author

nwaywood commented Mar 23, 2017

Yes the version of eslint I am using is ^3.14.1, I just updated eslint to the latest (^3.18.0) and I get the same error. Would you like me to test a different version?

Edit: After restarting atom it works on version ^3.18.0! Thanks for your time, feel free to close issue :)

@not-an-aardvark
Copy link
Member

From your stack trace screenshot, I see that you're using eslint from atom. Have you tried restarting atom? I wonder if it's caching the version of eslint somehow.

(Apart from that, I'm not sure what the problem would be given that it seems to be working on master and for other people.)

@nwaywood
Copy link
Author

Sorry I made an edit to my previous comment, you most not have noticed it. After a restart of atom it is working now with version ^3.18.0 of eslint. I'll close this since its only an issue with an old version of eslint

@not-an-aardvark
Copy link
Member

Great, glad to hear it's working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants