Uncaught TypeError: Cannot read property 'start' of undefined #231
Comments
I tried creating a new js file in a new directory and couldn't reproduce this error. So I suspect that this has something to do with the structure of my project, but I don't know what that could be. It's a proprietary repo so I can't easily share. There is no .eslintrc, and the package.json is in a different subdirectory than the javascript I'm trying to format. |
This seems like there was an error trying to parse your code, and then for some reason, prettier returned that error object without including the |
If I copy and paste the contents of the file into a new file in a different directory prettier formats it with no problems. |
Hmm, very strange, here is the issue: prettier/prettier#2428 Without seeing the original error, I can't say what's going wrong. I will try and include a fix so that at least this original error gets passed through and we can see what Prettier doesn't like. |
Hi, first of all thanks for this amazing tool. Atom: 1.18.0 |
Just confirming this bug and that the fix was turning off "ESLint integration" as julenr suggested. |
Hmm, then that must mean this is an error with prettier-eslint, and not prettier itself? |
+1, oddly enough for me the error went away when I enabled |
Disabling ESLint did solve the problem for me. But I also use ESlint in a couple different projects, with different settings. So, would still like for it to work. |
Solved! Not sure why this had to happen this way, but here is the fix that worked for me:
Make sure to turn ESLint Integration back on and then reload the window or restart Atom |
Perhaps it was an old version of prettier with a different Error API or something? |
This is the error that triggers this issue for me:
|
This recent Atom PR seems to have a fix: atom/atom#14761 |
Hi, I had the same bug but from a different circumstances:
My Fix:
Hope this helps someone. |
Hi, Atom: 1.18.0 x64 Stack TraceUncaught TypeError: Cannot read property 'start' of undefined
Commands
Non-Core Packages
|
Hello, i have the same bug, disabling ESLint did not help. Atom: 1.17.2 x64 Stack TraceUncaught TypeError: Cannot read property 'start' of undefined
Commands
Non-Core Packages
|
I was having the same issue which seemed to be related to #169. Using @marcusmotill 's solution worked for me. |
Thanks @rpylipow That seems to have fixed the problem. |
Sorry but I am still having the problem. |
@robwise I love Prettier. Thanks for such an excellent productivity tool for developers! I had this same issue and disabling ESLint integration solved it for me. I looked into it a little further and here is what was causing the problem. I have the following ESLint rule in .eslintrc: Here is the code that was causing me trouble:
When I tried to use Prettier in Atom (ctrl-alt-f), I would get the error. But when I disabled ESLint integration, Prettier ran and changed this code to:
So it seems that Prettier is conflicting with my ESLint rule and throwing the error. FYI, I don't have either prettier or prettier-eslint installed as dependencies for the project. I am just using the prettier-atom plug-in (0.36.1) in Atom (1.18.0). Let me know if I can try anything else to help to better pinpoint the source of this issue. |
Following to @thoragio solution, mine was similar but with a different ESLint rule. In my case I had: "comma-dangle": [0] and it was causing the error. I have changed for "comma-dangle": ["error", "never"] and now it works fine. Hope this can help. Cheers |
All - we're getting a whole jumble of errors, some seem related some seem might not be. I think the key thing here is that when we went to using |
Previously, we were assuming all errors thrown during execution of the formatters were going to be syntax errors. However, this is not the case, so we must handle these errors elegantly by displaying them in a popup. Resolves #231
@robwise Passing |
I just installed v0.37.0. When I try to run prettier now on the same file, I get a red pop-up error window that says "prettier-atom failed: Cannot read property 'arrays' of undefined". |
this is fixed for me after upgrading to v0.37.0 🎉 |
@thoragio what's the trace? |
@robwise I get nothing in the console. Just the pop-up error mentioned above. |
@robwise When on
|
@egoens Yes it does, that looks like this is due to a prettier-eslint error, can you make an issue on that repo? |
FWIW, I was running into this issue and it seems it was caused by an invalid eslint rule: I had
...compared to possible |
@cspanring Thank you! I had it set to just Thanks again. |
It seems like this was the fix for several people. I wonder how we can make eslint config validation errors more obvious? It might need to go inside of prettier-eslint? |
As you mentioned above, the error bubbled up from prettier-eslint. A better error handling there, with a more verbose custom error message, would be helpful to the user to better understand what went wrong. I'm not familiar how Atom and it's plugin architecture work, so I can't really speak to if there's a way to catch those errors on your plugin level. E.g. if an error bubbles up from prettier-eslint, taking a good guess and displaying something "It looks like there's a problem with your eslint rules."? |
We can pretty much do whatever we want, I tried to write this plugin in such a way that it's mostly just a normal node program most of the time. On those occasions where it tries to mess with atom, it has to go through a clearly-defined (I hope) interface so you know when you're entering atom territory and it's more developer-friendly. Right now, if we received a syntax error, we use the linter package to display it inline with the error message. If it isn't a syntax error, we just have atom show a popup with the error message and the stack trace. If we get prettier-eslint to give us a better error, then it should show up without having to really change anything with this plugin. @cspanring Can you do me a favor? Can you go onto the prettier-eslint repo and make an issue there with how to reproduce and suggest they throw a better error? Once that's done, we can load it into the plugin here and make sure the error comes up properly. |
Closing as this actually seems to a prettier-eslint issue with how it displays errors |
[Enter steps to reproduce:]
Atom: 1.18.0 x64
Electron: 1.3.15
OS: Mac OS X 10.12.5
Thrown From: prettier-atom package 0.36.1
Stack Trace
Uncaught TypeError: Cannot read property 'start' of undefined
Commands
Non-Core Packages
The text was updated successfully, but these errors were encountered: