Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter crashes on 'Parsing error: Unexpected token' on OSX #225

Closed
nikogosovd opened this issue Mar 11, 2018 · 7 comments
Closed

Linter crashes on 'Parsing error: Unexpected token' on OSX #225

nikogosovd opened this issue Mar 11, 2018 · 7 comments

Comments

@nikogosovd
Copy link

After I finally made SL4 work with SL-eslint I faced with annoying problem: linter crashes on any Parsing error — Sublime Text 3 console appears with the following message:

SublimeLinter: #6 eslint index.js ERROR:

 Linter crashed.

Traceback (most recent call last):
  File "lint.backend in /Users/<usr>/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 97, in execute_lint_task
  File "lint.linter in /Users/<usr>/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 813, in lint
  File "linter in /Users/<usr>/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-eslint.sublime-package", line 76, in find_errors
KeyError: 'ruleId'

At the same time CLI eslint works perfectly. SL-eslint correctly detects and highlights all other warnings and errors.

The following modules installed globally: babel-eslint, eslint, eslint-plugin-react in ~/.nvm/versions/node/v9.8.0/lib/node_modules.

eslint symlink is in ~/.nvm/versions/node/v9.8.0/bin pointing to ~/.nvm/versions/node/v9.8.0/lib/node_modules/eslint/bin/eslint.js.

SublimeFixMacPath is installed.

My local .eslintrc is here.

@kaste
Copy link
Contributor

kaste commented Mar 11, 2018

Please post thejson output eslint produces here.

@kaste
Copy link
Contributor

kaste commented Mar 11, 2018

Just switch the format to json.

It seems that your eslint produces different output for parse errors than mine.

@nikogosovd
Copy link
Author

nikogosovd commented Mar 11, 2018

When SL-eslint works normally, CLI eslint outputs e.g. the following:

➜  Project1 git:(master) ✗ eslint index.js -f json

[{
  "filePath": "/Users/<usr>/dev/Project1/index.js",
  "messages": [{
    "ruleId": "no-trailing-spaces",
    "severity": 2,
    "message": "Trailing spaces not allowed.",
    "line": 1,
    "column": 14,
    "nodeType": "Program",
    "source": "'use strict'; ",
    "fix": {
      "range": [13, 14],
      "text": ""
    }
  },
  {
    "ruleId": "quotes",
    "severity": 1,
    "message": "Strings must use singlequote.",
    "line": 3,
    "column": 27,
    "nodeType": "Literal",
    "source": "import { Component } from \"react\";",
    "endLine": 3,
    "endColumn": 34,
    "fix": {
      "range": [42, 49],
      "text": "'react'"
    }
  }],
  "errorCount": 1,
  "warningCount": 1,
  "fixableErrorCount": 1,
  "fixableWarningCount": 1,
  "source": "'use strict'; \n\nimport { Component } from \"react\";\n\nclass SomeComponent extends Component {\n  render() {}\n}\n\nSomeComponent.propTypes = {\n\n};\n\n\nexport default SomeComponent;\n"
}]

When SL-eslint crashes, CLI eslint outputs e.g. the following:

➜  Project1 git:(master) ✗ eslint index.js -f json

[{
  "filePath": "/Users/<usr>/dev/Project1/index.js",
  "messages": [{
    "ruleId": null,
    "fatal": true,
    "severity": 2,
    "source": "  render() {}`",
    "message": "Parsing error: Unexpected token\n\n\u001b[0m \u001b[90m 4 | \u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 5 | \u001b[39m\u001b[36mclass\u001b[39m \u001b[33mSomeComponent\u001b[39m \u001b[36mextends\u001b[39m \u001b[33mComponent\u001b[39m {\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 6 | \u001b[39m  render() {}\u001b[32m`\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m   | \u001b[39m             \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 7 | \u001b[39m\u001b[32m}\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 8 | \u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 9 | \u001b[39m\u001b[32mSomeComponent.propTypes = {\u001b[39m\u001b[0m",
    "line": 6,
    "column": 14
  }],
  "errorCount": 1,
  "warningCount": 0,
  "fixableErrorCount": 0,
  "fixableWarningCount": 0,
  "source": "'use strict';\n\nimport { Component } from \"react\";\n\nclass SomeComponent extends Component {\n  render() {}`\n}\n\nSomeComponent.propTypes = {\n\n};\n\n\nexport default SomeComponent;\n"
}]

It seems that "ruleId": null is the reason of the crush.

@kaste
Copy link
Contributor

kaste commented Mar 12, 2018

I can't reproduce this 😡 . If I produce a parsing error, I also get ruleId: null but then in python land I see a ruleId: None which is 🆗 .

Can you enable debug mode in SublimeLinter and post the output we actually have in Sublime land. Currently, it outputs twice, first the json string, and after that the python patsed json object.

@kaste
Copy link
Contributor

kaste commented Mar 12, 2018

FWIW I developed this plugin using eslint v4.9.0

@nikogosovd
Copy link
Author

nikogosovd commented Mar 12, 2018

I tried the latest for today eslint v4.18.2 and the latest of v3. All the same.

SublimeLinter: SublimeLinter.sublime-package:256: detected syntax: javascript
SublimeLinter: #9 SublimeLinter.sublime-package:782: 'eslint' is linting 'index.js'
SublimeLinter: #9 SublimeLinter.sublime-package:1186: eslint: index.js ['/usr/local/bin/eslint', '--format', 'json', '--stdin', '--stdin-filename', '/Users/<usr>/Desktop/index.js']
SublimeLinter: #9 SublimeLinter.sublime-package:1189: eslint: cwd: /Users/<usr>/Desktop
SublimeLinter: #9 SublimeLinter.sublime-package:809: eslint output:
    [{"filePath":"/Users/<usr>/Desktop/index.js","messages":[{"fatal":true,"severity":2,"message":"Parsing error: Unterminated template","line":1,"column":16}],"errorCount":1,"warningCount":0}]
SublimeLinter: #9 SublimeLinter-eslint.sublime-package:60: eslint output:
[{'errorCount': 1,
  'filePath': '/Users/<usr>/Desktop/index.js',
  'messages': [{'column': 16,
                'fatal': True,
                'line': 1,
                'message': 'Parsing error: Unterminated template',
                'severity': 2}],
  'warningCount': 0}]
SublimeLinter: #9 __init__.py:1273: ERROR: Linter crashed.

Traceback (most recent call last):
  File "lint.backend in /Users/<usr>/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 97, in execute_lint_task
  File "lint.linter in /Users/<usr>/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 813, in lint
  File "linter in /Users/<usr>/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-eslint.sublime-package", line 76, in find_errors
KeyError: 'ruleId'

I see that somehow SL-eslint uses eslint from /usr/local/bin/eslint. And its version is 1.10.3 o_O
At the same time in the SL settings I explicitly specified the PATH as written here:

{
    "linters": {
        "eslint": {
            "disable": false,
            "args": [],
            "excludes": [],
            "env": {
              "PATH": "/Users/<usr>/.nvm/versions/node/v9.8.0/bin"
            }
        }
    }
}

/usr/local/bin/eslint pointed to /usr/local/lib/node_modules/eslint/bin/eslint.js. Why? Dunno.

I tried to relink /usr/local/bin/eslint to the "PATH" specified above and it works perfectly now!

Excuse me for such a stupid bug... All I had to do was look at the debug report carefully and mention /usr/local/bin/eslint. Thank you for the hint. I'm sorry I wasted your time.

Now I need to find out why I had eslint -> /usr/local/lib/node_modules/eslint/bin/eslint.js and what else could point to wrong place.

@kaste
Copy link
Contributor

kaste commented Mar 12, 2018

Now your default eslint was so old you probably hadn't nvm running at that time. We'll see if this issue comes up again, curious when they made 'ruleId' mandatory.

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

No branches or pull requests

2 participants