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

Invalid position given by 'jsdoc/check-types' #1192

Closed
brettz9 opened this issue Oct 31, 2018 · 1 comment
Closed

Invalid position given by 'jsdoc/check-types' #1192

brettz9 opened this issue Oct 31, 2018 · 1 comment

Comments

@brettz9
Copy link

brettz9 commented Oct 31, 2018

ESLint returned a point that did not exist in the document being edited.
Rule: jsdoc/check-types
Requested start point: 10:0 - 10:0

Debug information:

{
  "atomVersion": "1.32.0",
  "linterEslintVersion": "8.4.1",
  "linterEslintConfig": {
    "lintHtmlFiles": false,
    "useGlobalEslint": false,
    "showRuleIdInMessage": true,
    "disableWhenNoEslintConfig": true,
    "eslintrcPath": "",
    "globalNodePath": "",
    "advancedLocalNodeModules": "",
    "eslintRulesDirs": [],
    "disableEslintIgnore": false,
    "disableFSCache": false,
    "fixOnSave": false,
    "scopes": [
      "source.js",
      "source.jsx",
      "source.js.jsx",
      "source.babel",
      "source.js-semantic"
    ],
    "rulesToSilenceWhileTyping": [],
    "rulesToDisableWhileFixing": [],
    "ignoreFixableRulesWhileTyping": false
  },
  "eslintVersion": "5.8.0",
  "hoursSinceRestart": 3,
  "platform": "darwin",
  "eslintType": "local project",
  "eslintPath": "/Users/brett/svgedit/node_modules/eslint",
  "editorScopes": [
    "source.js",
    "comment.block"
  ]
}

FWIW, the sample I'm experimenting with is:

/**
 * Namespaces or tools therefor
 * @module namespaces
 * @license MIT
*/

/**
 * @interface
 * @param {string} name The color name
 * @returns {object} A color object
 */
function Color (name) {}

/**
 * Function representing a transparent color.
 * @implements {Color}
 */
function TransparentColor (a) {}

export {Color, TransparentColor};

Should this instead be reported to eslint-plugin-jsdoc?

@brettz9
Copy link
Author

brettz9 commented Nov 1, 2018

Ok, I've isolated the problem a little bit...

With this block...

if (typeof endColumn !== 'undefined' && typeof endLine !== 'undefined') {
eslintFullRange = true
// Here we always want the column to be a number
msgCol = Math.max(0, column - 1)
msgEndLine = endLine - 1
msgEndCol = endColumn - 1

...endColumn (I don't know about endLine, column, or line) can end being null as in my case, so msgEndCol = endColumn - 1 therefore gives null -1 -> 0 - 1 -> -1.

Therefore, when line

throwIfInvalidPoint(buffer, msgEndLine, msgEndCol)
is reached (i.e., throwIfInvalidPoint(buffer, msgEndLine, msgEndCol) checks the validity of a -1 indexed end column in a point), and not recognizing such an index, it throws, so we get the reported "Invalid position" error.

Changing line

if (typeof endColumn !== 'undefined' && typeof endLine !== 'undefined') {
instead to:

if (endColumn && typeof endLine !== 'undefined') {

...helps avoid entering the block when endColumn is null, and avoids the problem.

I don't know whether endColumn being null originates, however, and whether this indicates something needs to be done on the plugin end to prevent this, but even if it is, judging by the number of these errors I see in your tracker, I'd expect you'd want to address this on your end as well.

skylize added a commit that referenced this issue Feb 3, 2019
Fix behavior when endColumn or endLine is null

Fixes issues #1197, #1196, #1195, #1192
@UziTech UziTech closed this as completed Mar 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants