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

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

Closed
drzax opened this issue Feb 16, 2016 · 12 comments · Fixed by #220
Closed

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

drzax opened this issue Feb 16, 2016 · 12 comments · Fixed by #220
Labels

Comments

@drzax
Copy link

drzax commented Feb 16, 2016

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
Copy link
Member

What does your configuration file look like?

@drzax
Copy link
Author

drzax commented Feb 16, 2016

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
Copy link

ghost commented Feb 16, 2016

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

@drzax
Copy link
Author

drzax commented Feb 17, 2016

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

@ghost
Copy link

ghost commented Feb 17, 2016

@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
Copy link

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
Copy link
Member

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
Copy link
Author

drzax commented Feb 18, 2016

Thanks for quick fix.

@AlbertoFdzM
Copy link

👍 @Arcanemagus Thanks!!!

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

@glynnsmith
Copy link

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
Copy link
Member

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

@glynnsmith
Copy link

Will do. Cheers!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants