ricardofbarros / linter-js-standard

Atom linter plugin for JavaScript, using JavaScript Standard Style
https://atom.io/packages/linter-js-standard
MIT License
99 stars 48 forks source link

"Uncaught TypeError: Cannot read property 'replace' of undefined" when attempting to close tab #62

Closed shawninder closed 8 years ago

shawninder commented 9 years ago

Repro:

  1. Unknown (this happens once in a while, not systematically)
  2. Try closing a tab
  3. Observe the tab doesn't close and an error notification appears

Fix by triggering Window:reload and trying again

Atom Version: 1.0.19 System: Mac OS X 10.10.5 Thrown From: linter-js-standard package, v3.2.1

Stack Trace

Uncaught TypeError: Cannot read property 'replace' of undefined

At /Users/shawn/.atom/packages/linter-js-standard/lib/utils/style-settings.js:20

TypeError: Cannot read property 'replace' of undefined
  at Object.checkStyleSettings (/Users/shawn/.atom/packages/linter-js-standard/lib/utils/style-settings.js:20:34)
  at Object.module.exports.__cacheTextEditor (/Users/shawn/.atom/packages/linter-js-standard/lib/init.js:100:21)
  at storeSettings (/Users/shawn/.atom/packages/linter-js-standard/lib/init.js:63:14)
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
  at /Applications/Atom.app/Contents/Resources/app.asar/src/pane-container.js:320:34
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
  at Pane.module.exports.Pane.setActiveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:250:22)
  at Pane.module.exports.Pane.activateItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:314:21)
  at Pane.module.exports.Pane.activateItemAtIndex (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:308:19)
  at Pane.module.exports.Pane.activatePreviousItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:279:21)
  at Pane.module.exports.Pane.removeItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:396:16)
  at Pane.module.exports.Pane.destroyItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:466:16)
  at Pane.module.exports.Pane.destroyActiveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:443:12)
  at Workspace.module.exports.Workspace.destroyActivePaneItem (/Applications/Atom.app/Contents/Resources/app.asar/src/workspace.js:617:35)
  at Workspace.module.exports.Workspace.destroyActivePaneItemOrEmptyPane (/Applications/Atom.app/Contents/Resources/app.asar/src/workspace.js:656:21)
  at atom-workspace.atom.commands.add.core:close (/Applications/Atom.app/Contents/Resources/app.asar/src/workspace-element.js:290:30)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:245:29)
  at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:524:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:347:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:184:20)

Commands

  2x -3:17.2.0 core:backspace (atom-text-editor.editor.is-focused)
     -3:12.1.0 fuzzy-finder:toggle-file-finder (atom-text-editor.editor.is-focused)
     -3:10.5.0 command-palette:toggle (atom-text-editor.editor.mini.is-focused)
     -3:07.4.0 editor:consolidate-selections (atom-text-editor.editor.mini.is-focused)
     -3:07.4.0 core:cancel (atom-text-editor.editor.mini.is-focused)
  2x -3:06.6.0 script:run (atom-workspace.workspace.scrollbars-visible-when-scrolling.theme-atom-light-syntax.theme-atom-light-ui)
     -2:56.1.0 grammar-selector:show (atom-text-editor.editor.is-focused)
     -2:54.3.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -2:52.9.0 script:run (atom-text-editor.editor.is-focused)
     -2:34.9.0 settings-view:open (atom-text-editor.editor.is-focused)
     -2:23.5.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:05.2.0 core:close (atom-text-editor.editor.mini.is-focused)

Config

{
  "core": {
    "themes": [
      "atom-light-ui",
      "atom-light-syntax"
    ],
    "disabledPackages": [
      "welcome",
      "timecop",
      "symbols-view",
      "styleguide",
      "release-notes",
      "metrics",
      "bookmarks"
    ]
  },
  "linter-js-standard": {
    "honorStyleSettings": true
  }
}

Installed Packages

# User
atom-pair, v2.0.10
coffee-compile, v0.19.2
docs-snippets, v0.8.0
editorconfig, v1.2.0
emmet, v2.3.13
highlight-selected, v0.10.1
language-swift, v0.4.0
linter, v1.8.1
linter-htmlhint, v0.1.1
linter-js-standard, v3.2.1
linter-package-json-validator, v0.2.2
pretty-json, v0.4.1
script, v3.0.1
standard-formatter, v1.1.3
tree-view-git-status, v0.2.2

# Dev
No dev packages
ricardofbarros commented 9 years ago

Hmm as you said this isn't a systematic error, so it will be hard to replicate, but I will try.

Thanks @shawninder

shaungrady commented 9 years ago

I'm able to reliably replicate.

  1. Create new, unsaved file
  2. Type in some JS, such as {}, and set the syntax to JavaScript
  3. Switch to a different tab, then switch back to the new file. Poof, error.

Atom Version: 1.1.0 System: Mac OS X 10.11.1 Thrown From: linter-js-standard package, v3.2.1

Stack Trace

Uncaught TypeError: Cannot read property 'replace' of undefined

At /Users/shaun/.atom/packages/linter-js-standard/lib/utils/style-settings.js:20

TypeError: Cannot read property 'replace' of undefined
  at Object.checkStyleSettings (/Users/shaun/.atom/packages/linter-js-standard/lib/utils/style-settings.js:20:34)
  at Object.module.exports.__cacheTextEditor (/Users/shaun/.atom/packages/linter-js-standard/lib/init.js:100:21)
  at storeSettings (/Users/shaun/.atom/packages/linter-js-standard/lib/init.js:63:14)
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:86:11)
  at /Applications/Atom.app/Contents/Resources/app.asar/src/pane-container.js:333:27
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:86:11)
  at Pane.module.exports.Pane.setActiveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:247:22)
  at Pane.module.exports.Pane.activateItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:311:21)
  at tabs-tab.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/tabs/lib/tab-bar-view.js:210:24)
  at space-pen-ul.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4435:9)
  at space-pen-ul.elemData.handle (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4121:28)

Commands

     -5:39.2.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -5:38.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -5:38.4.0 atom-beautify:beautify-editor (atom-text-editor.editor)
     -5:37.5.0 core:select-all (atom-text-editor.editor.is-focused)
     -5:37.2.0 core:copy (atom-text-editor.editor.is-focused)
     -2:39.3.0 settings-view:open (atom-text-editor.editor.is-focused)
     -2:37.5.0 core:close (div.panels-item)
  2x -2:37.5.0 tree-view:reveal-active-file (atom-workspace.workspace.scrollbars-visible-always.theme-atom-material-syntax.theme-atom-dark-ui)
     -2:10.9.0 application:new-file (ul.list-inline.tab-bar.inset-panel)
     -2:10.9.0 tree-view:reveal-active-file (atom-workspace.workspace.scrollbars-visible-always.theme-atom-material-syntax.theme-atom-dark-ui)
     -2:07.7.0 grammar-selector:show (atom-text-editor.editor)
     -2:05.9.0 core:move-down (atom-text-editor.editor.mini.is-focused)
     -2:05.7.0 core:confirm (atom-text-editor.editor.mini.is-focused)
  3x -2:03.4.0 tree-view:reveal-active-file (atom-workspace.workspace.scrollbars-visible-always.theme-atom-material-syntax.theme-atom-dark-ui)
     -0:54.2.0 grammar-selector:show (atom-text-editor.editor)
  2x -0:50.7.0 tree-view:reveal-active-file (atom-workspace.workspace.scrollbars-visible-always.theme-atom-material-syntax.theme-atom-dark-ui)

Config

{
  "core": {
    "ignoredNames": [
      ".git",
      ".svn",
      ".DS_Store"
    ],
    "projectHome": "/Users/shaun/Repositories",
    "disabledPackages": [
      "atom-jade",
      "autocomplete-css",
      "autocomplete-paths",
      "linter-jshint"
    ],
    "destroyEmptyPanes": false,
    "followSymlinks": false,
    "themes": [
      "atom-dark-ui",
      "atom-material-syntax"
    ],
    "audioBeep": false
  },
  "linter-js-standard": {
    "lintMarkdownFiles": true,
    "showEslintRules": true,
    "checkStyleDevDependencies": true,
    "honorStyleSettings": true
  }
}

Installed Packages

# User
Sublime-Style-Column-Selection, v1.3.0
aligner, v0.17.1
aligner-ruby, v1.4.0
angularjs, v0.3.3
atom-beautify, v0.28.17
atom-material-syntax, v0.2.4
atom-ternjs, v0.8.4
auto-reveal-in-sidebar, v0.8.0
color-picker, v2.0.13
emmet, v2.3.14
file-icons, v1.6.11
highlight-column, v0.5.0
highlight-selected, v0.10.1
javascript-snippets, v1.0.0
language-haml, v0.23.5
language-jade, v0.6.2
linter, v1.10.0
linter-js-standard, v3.2.1
pain-split, v1.4.0
pigments, v0.18.1
project-manager, v2.6.5
ruby-slim, v0.2.0
standard-formatter, v1.2.0
sync-settings, v0.6.0
tag, v0.3.0

# Dev
No dev packages
despairblue commented 8 years ago

Happens also with the current beta (1.3.0-beta6).

despairblue commented 8 years ago

Happens because getPath returns undefined for a file that has not been saved.

sbromberger commented 8 years ago

This is still happening (v 3.2.1).

ricardofbarros commented 8 years ago

Merged a PR from @thtliife, should be fixed on the latest release.