Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Uncaught TypeError: Cannot read property 'start' of undefined #231

Closed
jessehattabaugh opened this issue Jul 7, 2017 · 36 comments
Closed
Labels

Comments

@jessehattabaugh
Copy link

[Enter steps to reproduce:]

  1. Open Javascript file
  2. Select text
  3. Select "format with prettier" from context menu

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

At /Users/jesse/.atom/packages/prettier-atom/dist/executePrettier/handleError.js:15

TypeError: Cannot read property 'start' of undefined
    at errorLine (/packages/prettier-atom/dist/executePrettier/handleError.js:15:19)
    at buildPointArrayFromPrettierErrorAndRange (/packages/prettier-atom/dist/executePrettier/handleError.js:24:22)
    at setErrorMessageInLinter (/packages/prettier-atom/dist/executePrettier/handleError.js:40:29)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:49:114
    at executePrettierOnBufferRange (/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:45:5)
    at /packages/prettier-atom/dist/manualFormat/index.js:22:12
    at Array.forEach (native)
    at formatSelectedBufferRanges (/packages/prettier-atom/dist/manualFormat/index.js:21:43)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:97:162
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:63:325
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:49:144
    at /packages/prettier-atom/dist/main.js:33:15)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:265:35)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:65)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:166:25)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchContextMenuCommand (/Applications/Atom.app/Contents/Resources/app/src/atom-environment.js:1320:34)
    at EventEmitter.outerCallback (/Applications/Atom.app/Contents/Resources/app/src/application-delegate.js:347:31)
    at emitThree (events.js:116:13)
    at EventEmitter.emit (events.js:194:7)

Commands

     -2:43.4.0 core:select-all (input.hidden-input)
     -2:40.8.0 prettier:format (div.line)
     -0:47.3.0 core:confirm (input.hidden-input)
     -0:18.1.0 fuzzy-finder:toggle-file-finder (atom-workspace.workspace.scrollbars-visible-when-scrolling.theme-one-dark-syntax.theme-one-dark-ui)
     -0:16.9.0 core:confirm (input.hidden-input)
     -0:14.4.0 core:select-all (input.hidden-input)
     -0:10.5.0 prettier:format (span.syntax--comment.syntax--line.syntax--double-slash.syntax--js)

Non-Core Packages

atom-beautify 0.30.3 
atom-language-velocity 1.1.0 
atom-terminal 0.8.0 
build 0.68.0 
build-gradle 0.6.0 
build-npm-apm 0.12.0 
busy 0.7.0 
busy-signal 1.4.3 
change-case 0.6.5 
editorconfig 2.2.2 
highlight-selected 0.13.1 
intentions 1.1.2 
language-gradle 0.0.3 
language-groovy 0.7.0 
linter 2.2.0 
linter-eslint 8.2.1 
linter-flow 5.6.0 
linter-ui-default 1.6.2 
minimap 4.28.2 
prettier-atom 0.36.1 
sort-lines 0.14.0 
Sublime-Style-Column-Selection 1.7.4 
terminal-plus 0.14.5 
@jessehattabaugh
Copy link
Author

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.

@robwise
Copy link
Collaborator

robwise commented Jul 7, 2017

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 loc property on it, which we were not anticipating would ever happen. I can write a fix that at least lets the error pass through so you can see what the original error from prettier was. I am going to create an issue over there and see what the deal is with this error API.

@robwise robwise added the bug label Jul 7, 2017
@jessehattabaugh
Copy link
Author

If I copy and paste the contents of the file into a new file in a different directory prettier formats it with no problems.

@robwise
Copy link
Collaborator

robwise commented Jul 7, 2017

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.

@julenr
Copy link

julenr commented Jul 8, 2017

Hi, first of all thanks for this amazing tool.
I have the same issue in Mac and PC and is related to ESLint. When I disable ESLint integration option, everything works fine.

Atom: 1.18.0
ESLint 4.1.1
prettier-atom: 0.36.1
OS: Mac OS X 10.12.5 and Win 10

@SeanBannister
Copy link

Just confirming this bug and that the fix was turning off "ESLint integration" as julenr suggested.

@robwise
Copy link
Collaborator

robwise commented Jul 9, 2017

Hmm, then that must mean this is an error with prettier-eslint, and not prettier itself?

@Sam1301
Copy link

Sam1301 commented Jul 10, 2017

+1, oddly enough for me the error went away when I enabled ESLint integration.

@jessehattabaugh
Copy link
Author

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.

@chrisbull
Copy link

chrisbull commented Jul 12, 2017

Solved!

Not sure why this had to happen this way, but here is the fix that worked for me:

npm install --save-dev prettier \
  prettier-eslint \
  prettier-eslint-cli \
  eslint-plugin-jsx-a11y@^4.0.0 \
  eslint-plugin-react@^6.9.0 \
  eslint-plugin-import \
  eslint-config-airbnb \
  eslint-config-airbnb-base

Make sure to turn ESLint Integration back on and then reload the window or restart Atom

@robwise
Copy link
Collaborator

robwise commented Jul 12, 2017

Perhaps it was an old version of prettier with a different Error API or something?

@jsnajdr
Copy link

jsnajdr commented Jul 13, 2017

This is the error that triggers this issue for me:

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".

    at Object.get babylon [as babylon] (/Users/jsnajdr/src/wp-calypso/node_modules/prettier/src/parser.js:16:12)
    at resolveParseFunction (/Users/jsnajdr/src/wp-calypso/node_modules/prettier/src/parser.js:35:21)
    at Object.parse (/Users/jsnajdr/src/wp-calypso/node_modules/prettier/src/parser.js:47:25)
    at formatWithCursor (/Users/jsnajdr/src/wp-calypso/node_modules/prettier/index.js:61:22)
    at format (/Users/jsnajdr/src/wp-calypso/node_modules/prettier/index.js:101:10)
    at Object.format (/Users/jsnajdr/src/wp-calypso/node_modules/prettier/index.js:325:12)
    at executePrettier (/Users/jsnajdr/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:19:38)
    at executePrettierOrPrettierEslint (/Users/jsnajdr/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:30:70)
    at executePrettierOnBufferRange (/Users/jsnajdr/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:39:21)
    at executePrettierOnCurrentBufferRange (/Users/jsnajdr/.atom/packages/prettier-atom/dist/manualFormat/index.js:27:10)
    at r (/Users/jsnajdr/.atom/packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /Users/jsnajdr/.atom/packages/prettier-atom/node_modules/lodash/lodash.min.js:97:162
    at r (/Users/jsnajdr/.atom/packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /Users/jsnajdr/.atom/packages/prettier-atom/node_modules/lodash/lodash.min.js:63:325
    at /Users/jsnajdr/.atom/packages/prettier-atom/node_modules/lodash/lodash.min.js:49:144
    at atom-workspace.lazyFormat (/Users/jsnajdr/.atom/packages/prettier-atom/dist/main.js:33:15)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:265:35)
    at /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:65
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:3:65)

@jsnajdr
Copy link

jsnajdr commented Jul 13, 2017

This recent Atom PR seems to have a fix: atom/atom#14761
I use Atom 1.18.0 and this PR was merged after the release.

@quizzy
Copy link

quizzy commented Jul 14, 2017

Hi, I had the same bug but from a different circumstances:

  • Created a fresh install of Create React App
  • Already had an existing install of the prettier-atom plugin with pre-existing settings
  • Opened App.js and saved it to invoke the 'Format Files on Save' option from `prettier-atom' plugin
  • Cannot read property 'start' of undefined error pops up and auto format doesn't happen.

My Fix:

  • .editorconfig file was missing - so I added it
  • Opened App.js and saved again - no issue and auto format occurs

Hope this helps someone.
And of course big thanks to the Prettier team for the hard work :D

@jjabraham
Copy link

jjabraham commented Jul 17, 2017

Hi,
i'me getting this bug as well. I'm not using ESLint in my project So I dont know if that's an issue. i have tried all of the fixes mentioned above but not luck.

Atom: 1.18.0 x64
Electron: 1.3.15
OS: Ubuntu 16.04.2
Thrown From: prettier-atom package 0.36.1

Stack Trace

Uncaught TypeError: Cannot read property 'start' of undefined

At /home/jabraham/.atom/packages/prettier-atom/dist/executePrettier/handleError.js:15

TypeError: Cannot read property 'start' of undefined
    at errorLine (/packages/prettier-atom/dist/executePrettier/handleError.js:15:19)
    at buildPointArrayFromPrettierErrorAndRange (/packages/prettier-atom/dist/executePrettier/handleError.js:24:22)
    at setErrorMessageInLinter (/packages/prettier-atom/dist/executePrettier/handleError.js:40:29)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:49:114
    at executePrettierOnBufferRange (/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:45:5)
    at executePrettierOnCurrentBufferRange (/packages/prettier-atom/dist/manualFormat/index.js:27:10)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:97:162
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:63:325
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:49:144
    at /packages/prettier-atom/dist/main.js:33:15)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:265:35)
    at /usr/share/atom/resources/app/src/command-registry.js:3:65
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/usr/share/atom/resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/usr/share/atom/resources/app/src/window-event-handler.js:3:65)

Commands

     -0:44.8.0 tree-view:show (atom-workspace.workspace.scrollbars-visible-always)
     -0:37 intentions:highlight (input.hidden-input)
     -0:36.8.0 prettier:format (input.hidden-input)

Non-Core Packages

atom-typescript 11.0.6 
atom-typescript-react-redux-snippets 0.3.5 
busy-signal 1.4.3 
file-icons 2.1.9 
highlight-selected 0.13.1 
intentions 1.1.2 
linter 2.2.0 
linter-ui-default 1.6.2 
local-history 4.3.0 
pigments 0.39.1 
prettier-atom 0.36.1 

@mmv08
Copy link

mmv08 commented Jul 18, 2017

Hello, i have the same bug, disabling ESLint did not help.

Atom: 1.17.2 x64
Electron: 1.3.15
OS: Ubuntu 16.04.2
Thrown From: prettier-atom package 0.36.1

Stack Trace

Uncaught TypeError: Cannot read property 'start' of undefined

At /home/mmv/.atom/packages/prettier-atom/dist/executePrettier/handleError.js:15

TypeError: Cannot read property 'start' of undefined
    at errorLine (/packages/prettier-atom/dist/executePrettier/handleError.js:15:19)
    at buildPointArrayFromPrettierErrorAndRange (/packages/prettier-atom/dist/executePrettier/handleError.js:24:22)
    at setErrorMessageInLinter (/packages/prettier-atom/dist/executePrettier/handleError.js:40:29)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:49:114
    at executePrettierOnBufferRange (/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:45:5)
    at executePrettierOnCurrentBufferRange (/packages/prettier-atom/dist/manualFormat/index.js:27:10)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:97:162
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:5:165)
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:63:325
    at /packages/prettier-atom/node_modules/lodash/lodash.min.js:49:144
    at /packages/prettier-atom/dist/main.js:33:15)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:265:1)
    at /usr/share/atom/resources/app/src/command-registry.js:3:1
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:1)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:1)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/usr/share/atom/resources/app/src/window-event-handler.js:100:1)
    at HTMLDocument.<anonymous> (/usr/share/atom/resources/app/src/window-event-handler.js:3:1)

Commands

     -0:43.4.0 core:save (input.hidden-input)
  2x -0:33.9.0 editor:newline (input.hidden-input)
     -0:32 core:move-down (input.hidden-input)
  2x -0:31.7.0 autocomplete-plus:confirm (input.hidden-input)
     -0:29 editor:newline (input.hidden-input)
     -0:26.7.0 core:backspace (input.hidden-input)
     -0:25.7.0 autocomplete-plus:confirm (input.hidden-input)
  2x -0:24.3.0 core:backspace (input.hidden-input)
     -0:22.4.0 autocomplete-plus:confirm (input.hidden-input)
     -0:20.2.0 intentions:highlight (input.hidden-input)
     -0:20.1.0 core:save (input.hidden-input)
     -0:18.9.0 core:move-down (input.hidden-input)
     -0:18.3.0 intentions:highlight (input.hidden-input)
     -0:18.1.0 core:save (input.hidden-input)
     -0:17.6.0 intentions:highlight (input.hidden-input)
     -0:17.1.0 prettier:format (input.hidden-input)

Non-Core Packages

atom-clock 0.1.13 
atom-material-syntax-dark 1.0.0 
atom-material-ui 2.0.4 
autocomplete-modules 1.6.10 
busy-signal 1.4.3 
emmet 2.4.3 
file-icons 2.1.9 
git-plus 7.9.3 
intentions 1.1.2 
language-babel 2.67.0 
linter 2.2.0 
linter-ui-default 1.6.2 
minimap 4.28.3 
prettier-atom 0.36.1 
pure-syntax 0.3.0 
react-snippets 0.8.0 

@rpylipow
Copy link

I was having the same issue which seemed to be related to #169. Using @marcusmotill 's solution worked for me.

@jjabraham
Copy link

Thanks @rpylipow That seems to have fixed the problem.

@julenr
Copy link

julenr commented Jul 19, 2017

Sorry but I am still having the problem.
When I change tabWidth: "2" to tabWidth" 2 Atom removes this line and the problem continues.

@thoragio
Copy link

thoragio commented Jul 19, 2017

@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:
"operator-linebreak": [2, "after"]

Here is the code that was causing me trouble:

    case HIDE_MSG:
      const newState = state.isShowing === payload.id ?
      Object.assign({}, state, { isShowing: '' }) :
      Object.assign({}, state);
      return newState;

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:

    case HIDE_MSG:
      const newState =
        state.isShowing === payload.id
          ? Object.assign({}, state, { isShowing: '' })
          : Object.assign({}, state);
      return newState;

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.

@julenr
Copy link

julenr commented Jul 19, 2017

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

@robwise
Copy link
Collaborator

robwise commented Jul 22, 2017

@thoragio Going by @julenr's comment, can you try changing your rule to:

"operator-linebreak": ["always", "after"]

If this is the case, it sounds like there is a problem with how the prettier-eslint repo is reading the config?

@robwise
Copy link
Collaborator

robwise commented Jul 22, 2017

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 linter to display syntax errors inline, I didn't consider that we may have non-syntax-related errors that need to be displayed by other means. I'm going to add the popup-style errors we used to have for the cases where the errors aren't syntax errors. This will allow you to better see the error messages being thrown.

robwise added a commit that referenced this issue Jul 22, 2017
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
@thoragio
Copy link

@robwise Passing "operator-linebreak": ["always", "after"] was invalid, but I tried both "operator-linebreak": [0, "after"] and "operator-linebreak": [1, "after"] and in both cases I got the same error as mentioned at the start of this thread.

@thoragio
Copy link

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".

@Sam1301
Copy link

Sam1301 commented Jul 23, 2017

this is fixed for me after upgrading to v0.37.0 🎉

@robwise
Copy link
Collaborator

robwise commented Jul 23, 2017

@thoragio what's the trace?

@thoragio
Copy link

@robwise I get nothing in the console. Just the pop-up error mentioned above.

image

@egoens
Copy link

egoens commented Aug 2, 2017

@robwise When on v0.37.0 there is no stack trace. If I roll back to v0.35.0 I get the TypeError: Cannot read property 'arrays' of undefined error with a stack trace included. Hope this helps:

TypeError: Cannot read property 'arrays' of undefined
Hide Stack Trace
TypeError: Cannot read property 'arrays' of undefined
    at getValFromTrailingCommaConfig (/Users/egoens/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:222:45)
    at getTrailingComma (/Users/egoens/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:211:21)
    at configureOptions (/Users/egoens/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:164:20)
    at /Users/egoens/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:145:12
    at Array.reduce (native)
    at getPrettierOptionsFromESLintRules (/Users/egoens/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:144:38)
    at getOptionsForFormatting (/Users/egoens/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:99:18)
    at format (/Users/egoens/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/index.js:87:62)
    at /Users/egoens/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:23:12
    at exports.allowUnsafeNewFunction (/Users/egoens/.atom/packages/prettier-atom/node_modules/loophole/lib/loophole.js:25:14)
    at executePrettierEslint (/Users/egoens/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:22:10)
    at executePrettierOrPrettierEslint (/Users/egoens/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:29:32)
    at executePrettierOnBufferRange (/Users/egoens/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:38:21)
    at formatOnSaveIfAppropriate (/Users/egoens/.atom/packages/prettier-atom/dist/formatOnSave/index.js:14:122)
    at lazyFormatOnSave (/Users/egoens/.atom/packages/prettier-atom/dist/main.js:39:15)
    at /Users/egoens/.atom/packages/prettier-atom/dist/main.js:103:14
    at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)
    at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)
    at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1119:26)
    at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1108:25)
    at TextEditor.module.exports.TextEditor.save (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:925:32)
    at Pane.module.exports.Pane.saveItem (/Applications/Atom.app/Contents/Resources/app/src/pane.js:780:24)
    at Pane.saveItem (/Applications/Atom.app/Contents/Resources/app/src/pane.js:3:65)
    at Pane.module.exports.Pane.saveActiveItem (/Applications/Atom.app/Contents/Resources/app/src/pane.js:763:25)
    at Workspace.saveActivePaneItem (/Applications/Atom.app/Contents/Resources/app/src/workspace.js:1548:46)
    at atom-workspace.core:save (/Applications/Atom.app/Contents/Resources/app/src/register-default-commands.js:236:38)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:265:35)
    at /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:65
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:3:65)

@robwise
Copy link
Collaborator

robwise commented Aug 3, 2017

@egoens Yes it does, that looks like this is due to a prettier-eslint error, can you make an issue on that repo?

@cspanring
Copy link

cspanring commented Aug 8, 2017

FWIW, I was running into this issue and it seems it was caused by an invalid eslint rule: I had

'comma-dangle': ['off'],

...compared to possible comma-dangle options listed on http://eslint.org/docs/rules/comma-dangle. prettier-eslint was tripping over that (thanks @egoens for the stack trace!).

@thoragio
Copy link

thoragio commented Aug 9, 2017

@cspanring Thank you! I had it set to just [0] in my linting rules, but changing it to ["error", "never"] has fixed it for me.

Thanks again.

@robwise
Copy link
Collaborator

robwise commented Aug 10, 2017

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?

@robwise robwise reopened this Aug 10, 2017
@cspanring
Copy link

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 was refactoring the method in question, when I figured out that my eslint rule is off. I can try go in again and see if there's room for better error handling.

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."?

@robwise
Copy link
Collaborator

robwise commented Aug 10, 2017

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.

@robwise
Copy link
Collaborator

robwise commented Aug 27, 2017

Closing as this actually seems to a prettier-eslint issue with how it displays errors

@robwise robwise closed this as completed Aug 27, 2017
@robwise robwise added question and removed bug labels Aug 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests