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

"Error: Cannot mark location in editor for ..." popping up in Atom #700

Closed
chesterhow opened this issue Sep 13, 2016 · 48 comments
Closed

"Error: Cannot mark location in editor for ..." popping up in Atom #700

chesterhow opened this issue Sep 13, 2016 · 48 comments

Comments

@chesterhow
Copy link

chesterhow commented Sep 13, 2016

screen shot 2016-09-13 at 11 54 42 am

I'm getting these pop up errors while coding. Can't seem to figure out what's causing the issue. It was working just fine last Friday. Might have been caused by the recent v7.3.1 release?

I've tried reinstalling linter-eslint multiple times but still no luck. Any ideas?

@yourfavorite
Copy link

+1. Also having this issue since the update.

@yourfavorite
Copy link

For anyone else having this issue, here is a temporary solve to revert to 7.2.4 which doesn't have this issue. (Tried 7.3.0 which still had this issue)

  1. Uninstall linter-eslint in Atom
  2. Quit Atom
  3. In terminal run the following command apm install linter-eslint@7.2.4
  4. Start Atom

This should get you up and running again.

@chesterhow
Copy link
Author

@yourfavorite Worked for me too. Thanks! Hopefully this gets resolved soon.

@scholtzm
Copy link

screen shot 2016-09-13 at 09 04 24

Here's an example of this error while the ESLint failed to parse the code.

@IanVS
Copy link
Member

IanVS commented Sep 13, 2016

Thanks for the reports. These errors happen when ESLint reports an invalid rule/column location of an error. linter-eslint became much more sensitive to them in 7.3.0, which is why we're just seeing these errors now.

It would be very helpful if you could share the snippet of code that caused the error, so that we can reproduce and file an issue at ESLint. Or, if you can create a reproducible case, feel free to file the issue at ESLint yourself.

Downgrading to linter-eslint 7.2.4 will make the errors go away, but it will also not help us find and solve the underlying errors in ESLint, so if all possible it would be great if you could stick with 7.3.1 and report the error messages like you've been doing, plus the section of code that is failing.

Thanks for your help!

@chesterhow
Copy link
Author

chesterhow commented Sep 13, 2016

@IanVS Hey thanks for getting back to us. I don't think any specific snippet of code caused the errors because it was occurring in every file. I kinda suspect it might be due to my .eslintrc file although I'm not entirely sure.

Here's the .eslintrc file for my project. Sorry if it's a little messy 😅

{
  "extends": "airbnb",
  "parserOptions": {
    "ecmaVersion": 6,
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true,
    },
  },
  "env": {
    "browser": true,
    "node": true,
    "mocha": true
  },
  "plugins": [
    "react"
  ],
  "rules": {
    // Allow use of square-bracket notation
    "dot-notation": 0,
    // Allow use of alert, confirm or prompt functions
    "no-alert": 0,
    // Give a warning if identifiers contain underscores
    "no-underscore-dangle": 1,
    // Disable prop-types
    "no-class-assign": 0,
    "no-param-reassign": 0,
    // Default to single quotes and raise an error if something else is used
    "quotes": [2, "single"],
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
    // Deal with immutable.js collections ex. "Set, List, Map"
    "new-cap": ["error", { "capIsNew": false }],
    "import/no-extraneous-dependencies": ["error", { "devDependencies": true }]
  }
}

@IanVS
Copy link
Member

IanVS commented Sep 13, 2016

@chesterhow, are you sure you get the same error on every file? I assume the finalTime variable is defined in only one file, since it's not in a globals section of your config.

@neurosnap
Copy link
Contributor

Going from:

const { checkStatus } = errorUtil;

export function* onSendEmail(action) {

To:

const { checkStatus } = errorUtil;



export function* onSendEmail(action) {

screen shot 2016-09-13 at 9 45 07 am

@helly0d
Copy link

helly0d commented Sep 13, 2016

Error: Cannot mark location in editor for (no-multiple-empty-lines) - (More than 2 blank lines not allowed.) at line (33) column (2)
Error: Cannot mark location in editor for (no-multiple-empty-lines) - (More than 2 blank lines not allowed.) at line (33) column (2)
at /home/jarvis/.atom/packages/linter-eslint/lib/main.js:146:21
at Array.map (native)
at /home/jarvis/.atom/packages/linter-eslint/lib/main.js:125:27

This is the error I receive every time I have more than 2 empty lines. In my .eslintrc I have defined

"no-multiple-empty-lines": [1, {"max": 2}]

If I change this to "max": 4 it will trigger the error when I make the fifth empty line.

From what I've tested, this is the only rule that is triggering errors.
Hope this helps.

@IanVS
Copy link
Member

IanVS commented Sep 13, 2016

For those of you getting errors on no-multiple-empty-lines, please update to ESLint 3.5.0, and they will go away. Thats the only rule we've fixed in ESLint so far.

@JonathanWolfe
Copy link

This bug is caused by the "fix on save" feature and a race condition in the linter, @IanVS.

The linter tries to place the markers for the errors and warnings, but the fixer is currently swapping out the contents of the editor with the fixed version and thus the location the linter is trying to mark is no longer present.

@IanVS
Copy link
Member

IanVS commented Sep 13, 2016

@JonathanWolfe are you saying you're getting the error when you save the file? it's entirely possible that a case like that does cause the error in some situations, but many people are seeing the error even when they are not saving.

@JonathanWolfe
Copy link

JonathanWolfe commented Sep 13, 2016

@IanVS That is the only time I get the errors. I did see the error more often before updating Eslint, but now that's the only time.

@chesterhow
Copy link
Author

@IanVS Yea sorry a bit of miscommunication here. The errors I was referring to was the Error: Cannot mark location in editor for (*some-eslint-rule*) ... error and not the specific errors shown in my screen shot. These errors pop up in all of my JS files.

I've also updated ESLint to 3.5.0 and the no-multiple-empty-lines error no longer shows up but the rest still do.

@IanVS
Copy link
Member

IanVS commented Sep 13, 2016

@chesterhow it would be very helpful if you could provide an example both the error message as well as a line of code that the error references.

@JonathanWolfe Thanks, we'll have to look into this. Actually, could you make a separate issue for the error when autofixing, so it doesn't get lost in this thread which I expect will get pretty unwieldy.

@chesterhow
Copy link
Author

@IanVS Well this is awfully embarrassing.. To be really honest here, I can't seem to find a fixed series of steps which will reproduce the error. Each time I try to get it to appear nothing seems to happen. But after trying for a couple of minutes it would pop up again.

I have an example here but I don't really know the exact steps because it just happened while I was typing abcd.

Code
screen shot 2016-09-14 at 12 32 39 am

Error
screen shot 2016-09-14 at 12 28 25 am

Exact Error Message

Error: Cannot mark location in editor for (semi) - (Missing semicolon.) at line (2) column (24)
    at /Users/Chester/.atom/packages/linter-eslint/lib/main.js:146:21
    at Array.map (native)
    at /Users/Chester/.atom/packages/linter-eslint/lib/main.js:125:27

Note: column (24) is where my cursor is in the code screen shot.

I'll try to find a better example tomorrow, but in the meantime if anyone else knows how to replicate the error please do help us out 🆘

@webbower
Copy link

This bug is caused by the "fix on save" feature and a race condition in the linter - @JonathanWolfe

@IanVS This happens while I'm editing the file without triggering a save. I've seen all of the screenshot errors so far pop up in my workflow.

@Arcanemagus
Copy link
Member

Let's try to clean things up a bit here, as this thread is becoming a mess.

First of all, these are not all the same bug! The string inside the first () is the rule that triggered the message, inside the second () is the message from that rule. The line and column are 0-indexed values representing where the rule said the error was... which at the time we tried to mark it, wasn't a position that was valid in the file.

As it is the most common mentioned in this thread, and part of the first report, let's focus this issue on the semi rule. So if you are seeing a message that has anything other than (semi) as the first part, please file a new issue as you are not seeing the same thing!

When reporting a new issue please share your ESLint configuration, and a file that can reproduce this. We can help trace down what the minimal case is and report it over on ESLint so it can get fixed. If you can't find a file state that shows the error, a recording (GIF, YouTube, ...) of your Atom window when this happens for you might help to track it down.

For anyone seeing the semi rule misbehave, the above applies to you as well as we can't test anything without a way to reproduce it.

@webbower
Copy link

@Arcanemagus I think the common thread here (and the heart of the bug) is the "Cannot mark location in editor for (...)" aspect. And it seems to be affecting specific rules. The marking works fine for most rules in my case. There's just a handful of rules that this plugin seems to be having trouble figuring out where to mark it in Atom.

@IanVS
Copy link
Member

IanVS commented Sep 14, 2016

@webbower We have found (and fixed) one rule in ESLint which was reporting an invalid location (a column number which did not exist in the file). Our working hypothesis is that there are more such rules, and we are hoping that users can help us find them so that we can fix them as well.

@myknbani
Copy link

Happens to me as well after update: linter-eslint 7.3.0 -> 7.3.1

Rule: no-multiple-blank-lines

Error: Cannot mark location in editor for (no-multiple-empty-lines) - (More than 2 blank lines not allowed.) at line (32) column (2)
Error: Cannot mark location in editor for (no-multiple-empty-lines) - (More than 2 blank lines not allowed.) at line (32) column (2)
    at /home/mikenbani/.atom/packages/linter-eslint/lib/main.js:146:21
    at Array.map (native)
    at /home/mikenbani/.atom/packages/linter-eslint/lib/main.js:125:27

@chesterhow
Copy link
Author

@myknbani This can be resolved by updating ESLint to 3.5.0 like @IanVS mentioned previously. Worked for me :)

For those of you getting errors on no-multiple-empty-lines, please update to ESLint 3.5.0, and they will go away. Thats the only rule we've fixed in ESLint so far.

@dev-pro-alexander-subota
Copy link

dev-pro-alexander-subota commented Sep 14, 2016

Problem is still exist:

Atom 1.10.2
eslint 3.5.0
linter-eslint 7.3.1

"eslintConfig": {
    "extends": "airbnb-base",
    "env": {
      "node": true,
      "browser": true
    }
 }
Error: Cannot mark location in editor for (no-console) - (Unexpected console statement.) at line (26) column (3)
    at /Users/alexander.subota/.atom/packages/linter-eslint/lib/main.js:146:21
    at Array.map (native)
    at /Users/alexander.subota/.atom/packages/linter-eslint/lib/main.js:125:27

@chesterhow
Copy link
Author

Okay, I've managed to find a working example to replicate the error for the Missing semicolon rule.

  1. In a new JS file declare a constant but leave out the semicolon
const testString1 =  'hello world'
  1. Hit enter twice then declare a second constant. Leave out the semicolon here too.
const testString1 = 'hello world'

const testString2 = 'goodbye world'
  1. Hit backspace and delete characters one at a time. The error should pop up somewhere around good
const testString1 = 'hello world'

const testString2 = 'go'

Screenshots for reference

screen shot 2016-09-14 at 4 06 45 pm

screen shot 2016-09-14 at 4 06 39 pm

@Arcanemagus
Copy link
Member

We've confirmed that there can be a race condition between when a lint is triggered, and when ESLint returns the results, where the text has changed in the meantime making the ranges returned by ESLint invalid.

We're thinking of a good solution for this, however that doesn't mean that when you have that message you are always hitting this race condition. If the message shows up every time you save the file (and make no changes between saving and the message showing up), then either comment here with the file and configuration if the first part of the error is (semi), or file a new bug if it is a different rule.

@Arcanemagus
Copy link
Member

v7.3.2 is released with a fix in place to hopefully stop the race condition errors. If you are still seeing errors please report them with the relevant ESLint config, your version of ESLint being used, and code to reproduce it. Thanks!

@mliq
Copy link

mliq commented Sep 15, 2016

Did not fix for me:

Error:

Error: Cannot mark location in editor for (no-multiple-empty-lines) - (More than 2 blank lines not allowed.) at line (201) column (2)
Error: Cannot mark location in editor for (no-multiple-empty-lines) - (More than 2 blank lines not allowed.) at line (201) column (2)
    at /Users/mliquori/Dropbox/config/atom/packages/linter-eslint/lib/main.js:155:21
    at Array.map (native)
    at /Users/mliquori/Dropbox/config/atom/packages/linter-eslint/lib/main.js:134:27

eslint version: 2.7.0

eslint config (.eslintrc):

{
    "extends": [
      "eslint-config-airbnb",
      "plugin:ava/recommended"
    ],
    "env": {
        "node": true,
        "browser": true,
        "es6": true
    },
    "parser": "babel-eslint",
    "parserOptions": {
      "ecmaVersion": 7,
      "sourceType": "module"
    },
    "plugins": [
        "jsx-a11y",
        "import",
        "ava"
    ],
    "rules": {
        "no-undef": 2,
        "no-use-before-define": [2, { "functions": false }],

        "new-cap": [2, { "capIsNew": false }],
        "no-console": 0,
        "comma-dangle": [2, "never"],
        "semi": [2, "always"],
        "indent": [2, 4, {"SwitchCase": 1}],
        "max-len": [2, {"code": 120, "tabWidth": 4, "ignoreUrls": true, "ignoreComments": true}],
        "valid-jsdoc": 2,
        // react
        "react/display-name": 2,
        "react/sort-comp": [0, {         // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
            "order": [
                "displayName",
                "propTypes",
                "contextTypes",
                "childContextTypes",
                "constructor",
                "getDefaultProps",
                "initialState",
                "getChildContext",
                "componentWillMount",
                "componentDidMount",
                "componentWillReceiveProps",
                "componentReceivedProps",
                "shouldComponentUpdate",
                "componentWillUpdate",
                "componentDidUpdate",
                "componentWillUnmount",
                "componentShouldRender",
                "/^on.+$/",
                "/^get.+$/",
                "/^render.+$/",
                "render",
                "compose"
            ]
        }],
        "react/jsx-indent-props": 0,
        "react/jsx-boolean-value": 0,
        /* "react/jsx-first-prop-new-line": "never, TODO: enable when updated to eslint-config-airbnb 8.0.0 */
        "react/jsx-max-props-per-line": [2, { "maximum": 1 }],
        "react/jsx-closing-bracket-location": [
            2,
            {
                "selfClosing": "after-props",
                "nonEmpty": "after-props"
            }
        ],


        // jsx-a11y
        "jsx-a11y/img-uses-alt": 2,
        "jsx-a11y/label-uses-for": 2,
        "jsx-a11y/redundant-alt": 0,

        "import/no-unresolved": 2,
        "import/named": 2,
        "import/namespace": 2,
        "import/default": 2,

        // ava
        "ava/assertion-arguments": "error",
        "ava/assertion-message": ["off", "always"],
        "ava/max-asserts": ["off", 5],
        # "ava/no-async-fn-without-await": "error",
        "ava/no-cb-test": "off",
        # "ava/no-duplicate-modifiers": "error",
        "ava/no-identical-title": "error",
        "ava/no-ignored-test-files": "error",
        "ava/no-invalid-end": "error",
        "ava/no-nested-tests": "error",
        "ava/no-only-test": "error",
        "ava/no-skip-assert": "error",
        "ava/no-skip-test": "error",
        "ava/no-statement-after-end": "error",
        "ava/no-todo-implementation": "error",
        "ava/no-todo-test": "warn",
        "ava/no-unknown-modifiers": "error",
        "ava/prefer-async-await": "error",
        "ava/prefer-power-assert": "off",
        "ava/test-ended": "error",
        "ava/test-title": ["error", "if-multiple"],
        "ava/use-t-well": "error",
        "ava/use-t": "error",
        "ava/use-test": "error",
        "ava/use-true-false": "error"
    }
}

@julioolvr
Copy link

Same as @mliq, with the same rule, but I tried a minimal example with eslint 3.5.0 and it seems to work fine. I'm using eslint 3.1.1 on my real project and I get the error there, so I assume it's an issue with the old version of eslint.

@Arcanemagus
Copy link
Member

Arcanemagus commented Sep 15, 2016

@mliq and @julioolvr as has been stated several times in this thread, that rule was fixed in eslint@3.5.0, you'll need to update to at least that version for that to be fixed.

(It's been broken since v1.8.0, only now was it caught!)

vvo pushed a commit to algolia/eslint-config-algolia that referenced this issue Sep 16, 2016
@BenoitAverty
Copy link

I still have the error.

Package.json (relevant) :

"devDependencies": {
    "babel-cli": "^6.14.0",
    "babel-plugin-transform-object-rest-spread": "^6.8.0",
    "babel-preset-es2015": "^6.14.0",
    "eslint": "^3.5.0",
    "eslint-config-airbnb": "^11.1.0",
    "eslint-plugin-import": "^1.15.0",
    "eslint-plugin-jsx-a11y": "^2.2.2",
    "eslint-plugin-react": "^6.2.2",
    "nodemon": "^1.10.2"
  }

.eslintrc:

{
  "extends": "airbnb",
  "rules": {
    "no-unused-expressions": 0,
    "space-infix-ops": 0,
    "default-case": 0,
    "no-else-return": 0,
    "brace-style": [2, "stroustrup"],
    "quote-props": [2, "consistent-as-needed"],
    "new-cap": 0,
    "react/jsx-filename-extension": 0,
    "import/no-extraneous-dependencies": 0
  },
  "parserOptions": {
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true
    }
  }
}

I noticed that this error happens mostly (maybe always) when I hit backspace on a line where there is a lint error (What @chesterhow found).

@IanVS
Copy link
Member

IanVS commented Sep 16, 2016

@BenoitAverty what error are you getting, and what version of linter-eslint are you using?

@BenoitAverty
Copy link

BenoitAverty commented Sep 16, 2016

linter-eslint is at the last version (7.3.2). For the specific case I was mentionning, I get the error regarding "missing-semicolon" rule. But I'm not sure if it's the only one.

@IanVS
Copy link
Member

IanVS commented Sep 16, 2016

@BenoitAverty have you tried restarting Atom after upgrading linter-eslint? (just trying to eliminate the obvious)

@BenoitAverty
Copy link

Well, not so obvious apparently. I haven't been able to reproduce since restarting atom. I thought I did, but apparently not. Thanks !

@IanVS
Copy link
Member

IanVS commented Sep 16, 2016

I should have said "eliminate the easy stuff". I don't know why, but I see a lot of errors that go away when Atom is restarted. Glad it's working now. You had me sweating. :)

@txusinho
Copy link

txusinho commented Sep 19, 2016

@IanVS and @Arcanemagus thanks for your time answering this thread. I solved my issue thanks to your comments.

You might want to mark this issue as solved

@IanVS
Copy link
Member

IanVS commented Sep 20, 2016

Yep, it seems that we are not seeing additional reports whereas we were being flooded with them before, so I'm going to close this issue. Thanks for your patience everyone!

@IanVS IanVS closed this as completed Sep 20, 2016
@scottp
Copy link

scottp commented Sep 20, 2016

This is marked as closed. I have updated everything as per instructions above. Still not resolved.

  • linter-eslint @ 7.3.2 (check update within Atom) (also tried command line install)
  • Atom @ 1.10.2
  • eslint @ v3.5.0

Upgraded all 3 to latest. Restarted. Any edit of JS file with error I get:

screen shot 2016-09-20 at 11 58 52 am

NOTE: ! I found the bug. The version of eslint in a specific package was old. Doing a "npm install eslint" in the package in question fixed it. But the global eslint was correct. The package should be checking the eslint version, because otherwise this is a very difficult task to debug, and it will keep happening for people until they manually upgrade eslint in each of their local repositories.

@IanVS
Copy link
Member

IanVS commented Sep 20, 2016

@scottp this is intended behavior. If you don't have Use global ESLint installation checked in the preferences, linter-eslint will use the eslint that is installed for the package. In fact, we recommend against having a global eslint whenever possible, as it can cause unnecessary confusion.

This is off topic for this thread, but one possible improvement we could make is to add a "debug" command which would print out the location of the eslint executable being used to lint the open file. Do you think something like that could have been useful to you?

@scottp
Copy link

scottp commented Sep 20, 2016

Hi @IanVS - Thanks for quick response and quick fix for this. I missed that option in the config and have set it now. However the issue is the bug error message, IMHO - ie. the atom module update now requires a newer version of eslint, but instead of saying that, reports a random error. Best practice would be to say the version is out of date - which can be checked through the library. Then this won't come up as an error for future people, they would then easily know how to fix it.

@Arcanemagus
Copy link
Member

@scottp It doesn't require a newer version of eslint at all, it's just reporting that eslint told it to mark a position that was invalid, which is a bug in eslint. You could either go to eslint@1.7.3 and it would work fine (for this specific rule!), or go to eslint@3.5.0 since the rule was broken in eslint@1.8.0 and fixed in eslint@3.5.0 thanks to users reporting this message here.

@simonecorsi
Copy link

Fixed as suggested by updating toeslint@3.5.0, thank you it was driving me insane!

@wsmd
Copy link

wsmd commented Sep 22, 2016

Fixed as suggested by updating toeslint@3.5.0, thank you it was driving me insane!

I can confirm that as well. Hopefully, it doesn't come back.

ockham added a commit to Automattic/wp-calypso that referenced this issue Sep 27, 2016
I've been recently seeing a lot of "Error: Cannot mark location in editor for (no-multiple-empty-lines)" errors in Atom.
AtomLinter/linter-eslint#700 claims that this can be fixed by updating eslint to >= 3.5.0.
After doing so (and restarting Atom), Atom seems to be able to mark the correct location with the corresponding warning again, and the error is gone.
ockham added a commit to Automattic/wp-calypso that referenced this issue Sep 27, 2016
I've been recently seeing a lot of "Error: Cannot mark location in editor for (no-multiple-empty-lines)" errors in Atom.
AtomLinter/linter-eslint#700 claims that this can be fixed by updating eslint to >= 3.5.0.
After doing so (and restarting Atom), Atom seems to be able to mark the correct location with the corresponding warning again, and the error is gone.
pablosichert referenced this issue in One-com/eslint-config-onelint-react Oct 20, 2016
@callumlocke
Copy link

This issue is closed, but I'm getting this bug today with linter-eslint v8.0.0.

@IanVS
Copy link
Member

IanVS commented Oct 26, 2016

@callumlocke, can you please open a new issue with the error you are seeing and the output of the debug command? Thanks.

@Bosworth99
Copy link

I'm on linter-eslint 8.0.0 / atom 1.1.2 / El Capitan.
Getting this error still - it is quite distracting.

Is there an accepted fix?

@IanVS
Copy link
Member

IanVS commented Nov 4, 2016

@Bosworth99 There are several possible reasons you're getting an error. Please open a new issue with as much information as possible.

@IanVS
Copy link
Member

IanVS commented Nov 4, 2016

If you are getting this error, it is not due to a problem within linter-eslint, but rather ESLint is providing incorrect positions.

If you are seeing an error which includes 'no-empty-lines, that error was fixed ineslint@3.5.0`.

If you are seeing an error with a different eslint rule name, please open a new issue and provide all of the information requested.

I'm going to lock this thread. Feel free to open a new issue if you are getting a new error.

@AtomLinter AtomLinter locked and limited conversation to collaborators Nov 4, 2016
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