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

Uncaught TypeError: Path must be a string. Received null #67

Closed
ryancole opened this issue Mar 5, 2017 · 11 comments
Closed

Uncaught TypeError: Path must be a string. Received null #67

ryancole opened this issue Mar 5, 2017 · 11 comments
Labels

Comments

@ryancole
Copy link
Contributor

ryancole commented Mar 5, 2017

[Enter steps to reproduce:]

  1. Honestly, I'm not sure. I'm simply saving a .js file, with format-on-save enabled. This was working like 10 minutes ago but is no longer working. After receiving the error a first time, I was prompted to updated Atom. I updated Atom and am still getting the error.

Atom: 1.14.4 x64
Electron: 1.3.13
OS: Microsoft Windows 10 Pro
Thrown From: prettier-atom package 0.21.0

Stack Trace

Uncaught TypeError: Path must be a string. Received null

At C:\Users\Ryan\AppData\Local\atom\app-1.14.4\resources\app.asar\src\pane.js:1045

TypeError: Path must be a string. Received null
    at assertPath (path.js:7:11)
    at Object.parse (path.js:952:5)
    at getDirFromFilePath (/packages/prettier-atom/dist/helpers.js:32:15)
    at /packages/prettier-atom/dist/helpers.js:27:61
    at /packages/prettier-atom/dist/helpers.js:27:55
    at getFilePathRelativeToEslintignore (/packages/prettier-atom/dist/helpers.js:42:5)
    at isFilePathEslintignored (/packages/prettier-atom/dist/helpers.js:97:83)
    at formatOnSaveIfAppropriate (/packages/prettier-atom/dist/formatOnSave.js:20:38)
    at lazyFormatOnSave (/packages/prettier-atom/dist/main.js:31:15)
    at /packages/prettier-atom/dist/main.js:45:12
    at Function.module.exports.Emitter.simpleDispatch (/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
    at TextBuffer.module.exports.TextBuffer.saveAs (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1060:20)
    at TextBuffer.module.exports.TextBuffer.save (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1049:19)
    at TextEditor.module.exports.TextEditor.save (/app.asar/src/text-editor.js:893:26)
    at Pane.module.exports.Pane.saveItem (/app.asar/src/pane.js:753:18)
    at Pane.saveItem (/app.asar/src/pane.js:3:59)
    at Pane.module.exports.Pane.saveActiveItem (/app.asar/src/pane.js:736:19)
    at Workspace.module.exports.Workspace.saveActivePaneItem (/app.asar/src/workspace.js:693:35)
    at /app.asar/src/register-default-commands.js:225:32)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
    at /app.asar/src/command-registry.js:3:59
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:599:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:390:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/app.asar/src/window-event-handler.js:106:36)
    at /app.asar/src/window-event-handler.js:3:59)

Commands

     -0:28.3.0 tree-view:show (atom-workspace.workspace.scrollbars-visible-always.theme-oceanic-next.theme-one-dark-ui)
     -0:23.1.0 core:save (input.hidden-input)

Non-Core Packages

autocomplete-modules 1.6.7 
file-icons 2.0.17 
language-babel 2.56.0 
language-graphql 0.8.0 
linter 1.11.23 
linter-eslint 8.1.2 
oceanic-next 1.0.0 
prettier-atom 0.21.0 
@skevy
Copy link
Contributor

skevy commented Mar 5, 2017

This is happening to me as well. It started occurring upon upgrading prettier-atom to 0.21.0

@robwise robwise added the bug label Mar 5, 2017
@robwise
Copy link
Collaborator

robwise commented Mar 5, 2017

I'm on it!

@thtliife
Copy link

thtliife commented Mar 5, 2017

@ryancole & @skevy if you just create an empty .eslintignore file in your project, the error goes away...
just a dirty workaround until @robwise fixes this...

robwise added a commit that referenced this issue Mar 5, 2017
There may be cases where an editor will return a null filePath (such as when saving a new file).
Previously, doing so would cause an error because we assumed its presence when looking for the
nearest `.eslintignore` file. The solution is to short-circuit this check if the filePath is not
present, since there's no way it can be ignored if it doesn't have a path anyway.

Fixes #67
@thtliife
Copy link

thtliife commented Mar 5, 2017

Wow @robwise that was FAST!
Loving this package btw.... :)

@robwise
Copy link
Collaborator

robwise commented Mar 5, 2017

@thtliife @ryancole @skevy I just released a new version that hopefully addresses the bug. I apologize; I had to change a bunch of stuff under the hood when integrating prettier-eslint and this bug crept in.

Could you update to the latest and verify that it fixes your use cases? I was able to reproduce locally and then my fix seemed to resolve it, but I just want to make sure you're all set.

Wow @robwise that was FAST!
Loving this package btw.... :)

So happy to hear it!

@techrah
Copy link

techrah commented Mar 6, 2017

I'm getting the same issue on version 0.21.1 but an empty .eslintignore does the trick.

@robwise
Copy link
Collaborator

robwise commented Mar 6, 2017

Okay, was a double bug, fixing that now

robwise added a commit that referenced this issue Mar 6, 2017
We were not properly handling the case where no `.eslintignore` was found when attempting to
determine whether to run `formatOnSave`. Now, if no `.eslintignore` is found, we short circuit and
assume the file is not ignored.

Fixes #67 (again)
@robwise
Copy link
Collaborator

robwise commented Mar 6, 2017

I was able to reproduce the eslintignore problem as well and wrote a fix that seems to resolve it. I got thrown off because I actually encountered and fixed an unreported bug the first time. This should now fix the actual bug you were describing. I just published 0.21.2. Can someone confirm the problem is solved?

@thtliife
Copy link

thtliife commented Mar 6, 2017

Confirmed fixed in v0.21.2
Thanks for the fast work @robwise :)

@skevy
Copy link
Contributor

skevy commented Mar 6, 2017

Thanks @robwise for the quick turnaround!!

@kentcdodds
Copy link
Member

Thanks @robwise! Take care of yourself :)

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

6 participants