AtomLinter / linter-jshint

Atom linter plugin for JavaScript, using jshint.
147 stars 36 forks source link

TypeError: Cannot read property 'length' of undefined #213

Closed drzax closed 8 years ago

drzax commented 8 years ago

I'm getting this error on every change after updating to 2.0.0.

TypeError: Cannot read property 'length' of undefined
    at TextBuffer.module.exports.TextBuffer.lineLengthForRow (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:457:29)
    at Object.<anonymous> ([...]/packages/linter-jshint/lib/main.js:138:57)
    at [object Generator].next (native)
    at step ([...]/packages/linter-jshint/lib/main.js:3:273)
    at process._tickCallback (node.js:368:9)
Arcanemagus commented 8 years ago

What does your configuration file look like?

drzax commented 8 years ago

Atom config is here and .jshintrc below.

{
    "curly": true,
    "eqeqeq": true,
    "immed": true,
    "latedef": false,
    "newcap": true,
    "noarg": true,
    "sub": true,
    "undef": true,
    "unused": true,
    "boss": true,
    "eqnull": true,
    "es5": false,
    "strict": false,
    "evil": true,
    "node": true,
    "browser": true,
    "globals": {
        "$": false,
        "_": false,
        "d3": false,
        "ABC": false
    },
    "smarttabs": true
}
ghost commented 8 years ago

Remove {"es5": false}, this option is deprecated, try to use "esversion" instead

drzax commented 8 years ago

@ndrrsn That doesn't appear to make any difference. Is there some reason you think the deprecated option is related to this bug?

ghost commented 8 years ago

@drzax sorry, it isn't related to es5, but it is related to esversion for sure. I have the same error in case of 5.

AlbertoFdzM commented 8 years ago

Same problem here

TypeError: Cannot read property 'length' of undefined
    at TextBuffer.module.exports.TextBuffer.lineLengthForRow (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:457:29)
    at Object.<anonymous> (/Volumes/Data/Users/esnealfe/.atom/packages/linter-jshint/lib/main.js:138:57)
    at [object Generator].next (native)
    at step (/Volumes/Data/Users/esnealfe/.atom/packages/linter-jshint/lib/main.js:3:273)
{
  "bitwise": true,
  "camelcase": false,
  "curly": true,
  "eqeqeq": true,
  "smarttab": true,
  "forin": true,
  "immed": true,
  "latedef": true,
  "newcap": true,
  "noarg": true,
  "noempty": true,
  "nonew": true,
  "plusplus": false,
  "quotmark": false,
  "regexp": true,
  "undef": false,
  "unused": false,
  "strict": false,
  "trailing": false,
  "boss": true,
  "debug": true,
  "eqnull": true,
  "es5": true,
  "esnext": true,
  "evil": true,
  "funcscope": true,
  "globalstrict": false,
  "iterator": true,
  "laxbreak": true,
  "proto": true,
  "scripturl": true,
  "supernew": true,
  "validthis": true,
  "browser": true,
  "jquery": true,
  "node": true,
  "laxcomma": true,
  "passfail": true,
  "globals": {
    "jQuery": true,
    "define": true
  },
  "white":true
}
Arcanemagus commented 8 years ago

Fixed in v2.0.2.

@AlbertoFdzM thanks for your config, that exposed the bug nicely. jshint was reporting "Errors" on line 0, col 0 about your config having two invalid options specified. Since we put in some manual checks on those columns to workaround some bugs in the parser that jshint uses and assumed that it always gave a positive position, this caused issues as we were asking Atom to give the length of row -1.

@ndrrsn for some reason if es5 is set to false jshint doesn't warn about it being deprecated, it's only if it is set to true that it prints the warning so I'm not sure how you were hitting this @drzax.

drzax commented 8 years ago

Thanks for quick fix.

AlbertoFdzM commented 8 years ago

:+1: @Arcanemagus Thanks!!!

PD: Yes I was checking my config after report this and there were a few props wrong.

glynnsmith commented 8 years ago

Hey. Still getting this error when enabling linting within inline <script> tags:

TypeError: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at TextBuffer.module.exports.TextBuffer.lineLengthForRow (C:\Users\Glynn\AppData\Local\atom\app-1.5.3\resources\app.asar\node_modules\text-buffer\lib\text-buffer.js:457:29)
    at Object.<anonymous> (C:/Users/Glynn/.atom/packages/linter-jshint/lib/main.js:141:57)
    at [object Generator].next (native)
    at step (C:\Users\Glynn\.atom\packages\linter-jshint\lib\main.js:3:273)
    at process._tickCallback (node.js:368:9)

My config.cson:

"*":
  "atom-jshint": {}
  "autocomplete-plus":
    enableAutoConfirmSingleSuggestion: false
  "color-picker":
    abbreviateValues: true
    automaticReplace: true
    randomColor: false
  core:
    audioBeep: false
    closeEmptyWindows: false
    destroyEmptyPanes: false
    disabledPackages: [
      "wrap-guide"
      "pigments"
      "minimap-pigments"
    ]
    openEmptyEditorOnStart: false
    themes: [
      "one-dark-ui"
      "base16-tomorrow-dark-theme"
    ]
  editor:
    fontFamily: "input mono light"
    fontSize: 12
    invisibles: {}
    lineHeight: 1.65
    normalizeIndentOnPaste: true
    preferredLineLength: 110
    scrollPastEnd: true
    softWrap: true
    zoomFontWhenCtrlScrolling: false
  "highlight-line": {}
  jslint:
    useFoldModeAsDefault: true
    validateOnChange: true
    validateOnSave: false
  linter:
    errorPanelHeight: 201
    showErrorTabLine: true
  "linter-htmlhint": {}
  "linter-jshint":
    lintInlineJavaScript: true
  "linter-scss-lint": {}
  minimap:
    plugins:
      linter: true
      pigments: true
  "one-dark-ui":
    layoutMode: "Spacious"
  pigments:
    delayBeforeScan: 2
    extendAutocompleteToColorValue: true
    extendAutocompleteToVariables: true
    groupPaletteColors: "by file"
    supportedFiletypes: [
      "*.html"
      "*.css"
      "*.scss"
    ]
  welcome:
    showOnStartup: false

I have no .jshintrc

Arcanemagus commented 8 years ago

@glynnsmith Please open a new issue, the one discussed earlier in this issue was fixed in v2.0.2.

glynnsmith commented 8 years ago

Will do. Cheers!