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

Parser error on files in node_modules #634

Closed
BarryThePenguin opened this issue Oct 20, 2016 · 5 comments · Fixed by #654
Closed

Parser error on files in node_modules #634

BarryThePenguin opened this issue Oct 20, 2016 · 5 comments · Fixed by #654

Comments

@BarryThePenguin
Copy link
Contributor

BarryThePenguin commented Oct 20, 2016

I'm not sure where this issue belongs, I thought I'd start here as it's related to the rules in this package.

I'm using this plugin as it's included with XO. I'm getting an error as a result of the following rules: import/no-named-as-default, import/no-named-as-default-member, import/default, import/namespace and import/named

Parse errors in imported module browser-sync: Unexpected character # (1:1)

This happens when I'm importing browser-sync. It looks as though BrowserSync has a #! /usr/bin/env node at the top of their main file, which I assume is causing the issue.

So appears there are a few things going on here:

  • eslint-plugin-import is parsing files in my node_modules folder. I haven't spent much time understanding how this plugin works, I just consume it through XO.
  • browser-sync has a #! /usr/bin/env node line at the top of their main file. I'm only aware of using this in node shell scripts, and I don't think the main BrowserSync file is a script
  • it looks like the eslint parser falls over when it encounters a # as the first character in a javascript module file

There's a few things here and I'm happy to follow up with any changes to the other projects, I just wanted to check with others that the above is correct. Thanks! 😀

@benmosher
Copy link
Member

Strange. I'm not sure where to go on this, though this file should never have been parsed to begin with, since it has no imports/exports. So this is related to #615 / #649.

I'm not sure how/if you can set ESLint settings in XO (@jfmengels?) but the same workaround for those issues should work for this too, until the root issue (overparsing of CJS node modules) is solved.

@benmosher benmosher added the bug label Nov 3, 2016
@benmosher benmosher modified the milestones: v3 - import/order internal, unambiguous regex false positives Nov 3, 2016
@jfmengels
Copy link
Collaborator

The way to set ESLint settings in XO is described here.

benmosher added a commit that referenced this issue Nov 5, 2016
benmosher added a commit that referenced this issue Nov 7, 2016
* fix logical gaffs preventing unambiguous regex from functioning properly.

fixes #615
fixes #634
fixes #649

* fixed typo 😅
@BarryThePenguin
Copy link
Contributor Author

Woo! 👏

@benmosher
Copy link
Member

@BarryThePenguin don't get your hopes up too high 😅 I'm pretty sure this should fix your issue without needing the aforementioned workaround, but not 100% sure. Let me know if it doesn't and I'll reopen.

@BarryThePenguin
Copy link
Contributor Author

I'm sure I'll keep you posted if I run into anymore trouble 😰

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

Successfully merging a pull request may close this issue.

3 participants