Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Catch Babel parsing errors #131

Closed
adrianmcli opened this issue Sep 24, 2017 · 9 comments
Closed

Catch Babel parsing errors #131

adrianmcli opened this issue Sep 24, 2017 · 9 comments

Comments

@adrianmcli
Copy link

adrianmcli commented Sep 24, 2017

When I'm editing .js files with the Stylelint plugin in VSCode, I get spammed with popup error messages from babylon.

For example:

SyntaxError: Unexpected token, expected ;(50:12) at Parser.pp$5.raise (/home/hugo/projects/liber/liber-app/node_modules/babylon/lib/index.js:4454:13) at Parser.pp.unexpected (/home/hugo/projects/liber/liber-app/node_modules/babylon/lib/index.js:1761:8) at Parser.pp.semicolon (/home/hugo/projects/liber/liber-app/node_modules/babylon/lib/index.js:1742:38) at Parser.pp$1.parseVarStatement (/home/hugo/projects/liber/liber-app/node_modules/babylon/lib/index.js:2170:8) at Parser.p

My .stylelintrc:

{
  "processors": ["stylelint-processor-styled-components"],
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-styled-components"
  ],
  "syntax": "scss"
}

Another user had the same problem here: https://github.com/shinnn/vscode-stylelint/issues/89

According to the author of the plugin, it seems that it's a bug with the processor (hence why I made this issue in this repo). He says it's because this processor does not adhere to the original stylelint behaviour to syntax errors as described here:

stylelint.lint() does not reject the Promise when your CSS contains syntax errors.

I'm completley new to Stylelint and I don't really know how it works, so this is where my research stopped. If anyone has some insight, that would be extremely helpful.

@mxstbr
Copy link
Member

mxstbr commented Sep 24, 2017

/cc @orta you're using this setup, right?

@orta
Copy link
Member

orta commented Sep 24, 2017

Yep, and a fail generally works fine for us:

screen shot 2017-09-24 at 6 34 26 am

The offsets are usually wrong, but we have a complicated babel setup running typescript first, so we just deal with it

@mxstbr
Copy link
Member

mxstbr commented Sep 24, 2017

Hmm interesting, so it's gotta be something in your local setup @adrianmcli. I don't know what this means or what we should have to change:

stylelint.lint() does not reject the Promise when your CSS contains syntax errors.

Note: I think the wrong offsets are due to #128 (see failing test in #129), any help getting that fixed appreciated too!

@orta
Copy link
Member

orta commented Sep 24, 2017

Form the sounds of it, the issue is that an exception is being raised in the babel parser that isn't being caught and returned as an object with the right formatting to say there is an issue. I don't think they ever expect you to be throwing an error, which seems like a reasonable assumption.

@adrianmcli
Copy link
Author

@orta

So are you not getting the popups that I am getting? And you are using the same vscode plugin with comparable configuration?

Also, would you have any idea as to why the author of the plugin thinks it's a bug with the processor? I'm just trying to find a solution here.

@orta
Copy link
Member

orta commented Sep 25, 2017

Nope, never seen popups like that - and yeah, I added the TypeScript support for that extension: https://github.com/shinnn/vscode-stylelint/pull/82

I think it's this: an exception is being raised in a babel parser in this lib that isn't being caught and then returned as an object with the right formatting to say there is an issue. I don't think they ever expect you to be throwing an error, which seems like a reasonable assumption

@emilgoldsmith
Copy link
Member

Okay @orta so you reckon this issue should for example be renamed to "Errors not being caught correctly" and we should add a .catch statement somehwere or something of the likes?

@orta
Copy link
Member

orta commented Sep 25, 2017

Yep 👍

@mxstbr mxstbr changed the title Error popups from linting with Stylelint in VSCode Catch Babel parsing errors Sep 25, 2017
@Undistraction
Copy link

Undistraction commented Nov 5, 2017

For what it's worth I have the same issue. The moment I start editing a JS file I get a deluge of alerts. It makes this plugin unusable unfortunately as my only option is to remove Javascript from stylelint's list of types.

I'm using the same VSCode plugin as the original poster. My .stylelintrc:

{
  "processors": ["stylelint-processor-styled-components"],
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-styled-components"
  ],
  "syntax": "css"
}

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

No branches or pull requests

5 participants