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 'style' of undefined #168

Closed edarblanco closed 7 years ago

edarblanco commented 7 years ago

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.14.4 x64 Electron: 1.4.15 OS: "Arch Linux" Thrown From: linter-js-standard package 3.9.0

Stack Trace

Uncaught TypeError: Cannot read property 'style' of undefined

At /home/edar/.atom/packages/linter-js-standard/lib/init.js:111

TypeError: Cannot read property 'style' of undefined
    at Object.__cacheTextEditor (/packages/linter-js-standard/lib/init.js:111:18)
    at storeSettings (/packages/linter-js-standard/lib/init.js:79:14)
    at Function.module.exports.Emitter.simpleDispatch (/usr/lib/atom/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/usr/lib/atom/node_modules/event-kit/lib/emitter.js:129:28)
    at /usr/lib/atom/src/pane-container.js:348:27
    at Function.module.exports.Emitter.simpleDispatch (/usr/lib/atom/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/usr/lib/atom/node_modules/event-kit/lib/emitter.js:129:28)
    at Pane.module.exports.Pane.setActiveItem (/usr/lib/atom/src/pane.js:300:22)
    at Pane.module.exports.Pane.activateItemAtIndex (/usr/lib/atom/src/pane.js:435:19)
    at Pane.module.exports.Pane.activatePreviousItem (/usr/lib/atom/src/pane.js:400:21)
    at Pane.module.exports.Pane.removeItem (/usr/lib/atom/src/pane.js:585:16)
    at Pane.module.exports.Pane.destroyItem (/usr/lib/atom/src/pane.js:658:16)
    at TabBarView.module.exports.TabBarView.closeTab (/usr/lib/atom/node_modules/tabs/lib/tab-bar-view.js:333:26)
    at HTMLDivElement.TabView.didClickCloseIcon (/usr/lib/atom/node_modules/tabs/lib/tab-bar-view.js:222:19)

Commands

     -9:20.7.0 tree-view:show (atom-workspace.workspace.scrollbars-visible-always.theme-atom-dark-fusion-syntax.theme-one-dark-ui)
     -9:14.1.0 editor:join-lines (input.hidden-input)
     -9:07.8.0 settings-view:open (input.hidden-input)
  2x -8:59.9.0 core:confirm (input.hidden-input)

Non-Core Packages

advanced-open-file 0.16.5 
angular-2 0.2.6 
angular-2-typeScript-snippets 0.6.3 
angular-bootstrap 1.0.1 
angular-restful-snippets 0.14.0 
angular2-snippets 0.3.0 
angularjs 0.4.0 
angularjs-snippets 0.10.18 
atom-beautify 0.29.17 
atom-bootstrap3 1.2.12 
atom-bootstrap4 1.4.0 
atom-dark-fusion-syntax 2.0.3 
express-complete 0.2.0 
autocomplete-angular-material 0.4.0 
autocomplete-modules 1.6.7 
cdn-libs 0.1.2 
color-picker 2.2.5 
css-snippets 1.1.0 
emmet 2.4.3 
expressjs 1.2.0 
file-icons 2.0.16 
flexbox-snippets 0.3.0 
git-plus 7.3.3 
git-plus-plus 1.1.0 
hyperclick 0.0.40 
js-hyperclick 1.10.1 
js-hyperx 1.1.0 
js-refactor 0.7.5 
language-babel 2.55.6 
language-graphql 0.8.0 
language-html-angular 1.0.16 
language-mongodb 0.3.1 
less-autocompile 1.0.0 
linter 1.11.23 
linter-eslint 8.1.2 
linter-js-standard 3.9.0 
linter-less 2.6.0 
linter-sass-lint 1.7.4 
linter-stylelint 3.9.0 
minimap 4.26.8 
minimap-autohide 0.10.1 
minimap-highlight-selected 4.5.0 
path-hyperclick 0.3.0 
pigments 0.39.0 
platformio-ide-terminal 2.3.1 
refactor 0.11.3 
rest-client 1.3.1 
smart-daemon-control 0.8.7 
template-generator 0.15.0 
todo-show 1.11.0 
ricardofbarros commented 7 years ago

Hey @edarblanco some steps to reproduce would be cool.

edarblanco commented 7 years ago

Oh, my apologies, but apparently I solved the problem precisely today, I deleted the configuration folder of the plugin and to reinstall it everything was perfect, I give the thread as closed, thanks

sonicdoe commented 7 years ago

I have just had the same issue with Atom v1.14.4 on macOS. To reproduce:

  1. touch foo.js
  2. atom foo.js
  3. Type something into foo.js but do not save the file
  4. Open another tab, for example Settings
  5. rm foo.js
  6. Switch back to foo.js in Atom
jarryd999 commented 7 years ago

This mostly happens to me when I switch between branches. I'll leave files open (in background tabs) that do not exist on another branch, and if I switch back to one of those tabs (manually or just when closing other tabs and they are supposed to come to the foreground) I run into this issue.

rankida commented 7 years ago

Yep I just got the same issue too

[Enter steps to reproduce:]

  1. I just opened my editor via atom .. I did have other instances of atom already open for different directories. Worth nothing that this was not a standardlinted project (just regular eslint) so I would not have expected anything from standard.

Atom: 1.15.0 x64 Electron: 1.3.13 OS: Mac OS X 10.11.6 Thrown From: linter-js-standard package 3.9.0

Stack Trace

Uncaught TypeError: Cannot read property 'style' of undefined

At /Users/rankida/.atom/packages/linter-js-standard/lib/init.js:111

TypeError: Cannot read property 'style' of undefined
    at Object.__cacheTextEditor (/packages/linter-js-standard/lib/init.js:111:18)
    at storeSettings (/packages/linter-js-standard/lib/init.js:79:14)
    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 /app.asar/src/pane-container.js:348:27
    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 Pane.module.exports.Pane.setActiveItem (/app.asar/src/pane.js:300:22)
    at Pane.module.exports.Pane.activateItem (/app.asar/src/pane.js:452:21)
    at TabBarView.module.exports.TabBarView.onMouseDown (/app.asar/node_modules/tabs/lib/tab-bar-view.js:678:19)

Commands

Non-Core Packages

atom-beautify 0.29.17 
atom-typescript 11.0.1 
busy-signal 1.3.0 
intentions 1.1.2 
linter 2.1.0 
linter-eslint 8.1.4 
linter-js-standard 3.9.0 
linter-ui-default 1.2.1 
platformio-ide-terminal 2.5.0 
react 0.16.2 
tjmehta commented 7 years ago

I repro'd this when I renamed a dir and touched files in atom with pathnames that did not exist (after the move).

tjmehta commented 7 years ago

When the file does not exist checkStyleSettings ignores the error, and returns undefined: https://github.com/ricardofbarros/linter-js-standard/blob/60643d80615f9f1133dc71370575ad2f25e29932/lib/utils/style-settings.js#L41

Which causes opts to be undefined here: https://github.com/ricardofbarros/linter-js-standard/blob/60643d80615f9f1133dc71370575ad2f25e29932/lib/init.js#L108

Which causes Cannot read property 'style' of undefined here: https://github.com/ricardofbarros/linter-js-standard/blob/60643d80615f9f1133dc71370575ad2f25e29932/lib/init.js#L111

whmountains commented 7 years ago

I get this error whenever I checkout a new branch with git. Atom suddenly randomly marks some tabs as unsaved and throws gazillions of these errors.

I can't say it happens 100% of the time, but definitely most of the time. I'd be happy to do debugging on my end if needed.

dcalhoun commented 7 years ago

@ricardofbarros will you please re-open this issue. It is definitely an active bug and there is now explicit steps to reproduce it.

edarblanco commented 7 years ago

Now this is my solution, save the atom package list, and remove or save in another location the atom packages configuration, and install with apm install the list of all the packages, for my work, but my problem was one package outdated

alancnet commented 7 years ago

My steps to reproduce:

  1. Create x.js
  2. Rename x.js to y.js
  3. Open y.js
  4. Select the x.js tab
whmountains commented 7 years ago

@alancnet Yes, I've frequently gotten that error doing similar actions.

But strangely I just tried it and couldn't manage to cause the error. Atom picked up the change immediately.

Maybe we're dealing with a sketchy file watcher here?

whmountains commented 7 years ago

I can reproduce the error by deleting a file that Atom currently has open in an inactive tab, then switching to the tab.

To eliminate as much unpredictability as possible, here is a command line that will generate the error 100% of the time.

touch foo.js && touch bar.js && atom foo.js && sleep 10 && rm foo.js && atom bar.js

Now just click back on the tab for foo.js and you'll see the error. At least I do, on Mac OS 10.12.4.

mattfysh commented 7 years ago

Create a new file and switch from, then switch to, the new file. Since atom hasn't created the file in the filesystem yet (because it hasn't yet been saved), this error will be thrown

reneolivo commented 7 years ago

Got the issue too....

mattfysh commented 7 years ago

I ended up switching to prettier

binarykitchen commented 7 years ago

come on, when will this be fixed??

binarykitchen commented 7 years ago

if i submit a pr would you accept it?

whmountains commented 7 years ago

I'll install from your fork if it doesn't get merged or fixed in some other way.

nikmartin commented 7 years ago

This bug is very reproducible when trying to edit JSX files with a .js extension. It makes atom unusable in fact since it pops up every time you try to switch tabs. Uninstalled linter-js-standard and installed prettier

binarykitchen commented 7 years ago

likewise, switched to prettier

laughedelic commented 7 years ago

I have this problem too. Almost 5 months, a lot of angry users and no reaction from the maintainer? Bad impression... 👎

sonicdoe commented 7 years ago

This will be fixed in an upcoming patch version.

sonicdoe commented 7 years ago

Released in v3.9.2 🎉