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

[import/default] False positive when parsing a file using ES7. #36

Closed
doctyper opened this issue Jul 16, 2015 · 6 comments
Closed

[import/default] False positive when parsing a file using ES7. #36

doctyper opened this issue Jul 16, 2015 · 6 comments

Comments

@doctyper
Copy link

When importing a module that contains stage 0 proposals, e.g.:

// Foo.jsx
class Foo {
    // ES7 static members
    static bar = true;
}

export default Foo;

// Importer.jsx
import Foo from "Foo"

I get the following false-positive:

error  No default export found in module  import/default

I dug into the code a bit and found Espree has issues parsing experimental code:

{ settings: 
   { 'import/ignore': [ 'node_modules' ],
     'import/resolve': { extensions: [Object], moduleDirectory: [Object] } },
  hasDefault: false,
  named: {},
  errors: 
   [ { [Error: Line 6: Unexpected token =]
       index: 185,
       lineNumber: 6,
       column: 24,
       description: 'Unexpected token =' } ] }

Note: We use babel-eslint in order to support linting with experimental code.

I'm not asking that you support experimental code (although it would be nice!), but it would be great if the parsing error was surfaced, or at the very least a note that this rule does not support experimental code.

@benmosher
Copy link
Member

There is a no-errors rule (off by default) that exists to warn on this sort of thing.

I just added some explicit tests (with your example file) and the ESLint tests report that no-errors should report for this.

@benmosher
Copy link
Member

I will investigate making babel-eslint a parser option. I'm not sure if it can be inferred from the rule context, but if nothing else it could be (re-)specified in an import/parser setting.

@doctyper
Copy link
Author

Thanks! That would be great, the rule is super useful.

@benmosher
Copy link
Member

Pushed with 0.7.2. Haven't tested significantly, but given that ESLint integrates with babel-eslint in the same way, I have high hopes!

@doctyper
Copy link
Author

@benmosher I finally had a chance to try this out. This is seriously awesome. It's parsing using babel-eslint with flying colors.

If you're ever in L.A. I will gladly take you out for 🍻.

@benmosher
Copy link
Member

😎

On Jul 18, 2015, at 12:58, Richard Herrera notifications@github.com wrote:

@benmosher I finally had a chance to try this out. This is seriously awesome. It's parsing using babel-eslint with flying colors.

If you're ever in L.A. I will gladly take you out for .


Reply to this email directly or view it on GitHub.

silverwind pushed a commit to silverwind/eslint-plugin-import that referenced this issue Jul 18, 2024
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