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

Ignore directives for imports-first #255

Closed
lemonmade opened this issue Apr 22, 2016 · 3 comments
Closed

Ignore directives for imports-first #255

lemonmade opened this issue Apr 22, 2016 · 3 comments

Comments

@lemonmade
Copy link
Contributor

We currently use a custom directive at the top of most JavaScript files. imports-first requires that any imports come before this line, but doing so means that it is no longer treated as a directive. I'm wondering if it would be possible to add an option to imports-first to ignore directives (which should be pretty easy to detect, even though I don't think ESLint exposes them as such). Basically, I would love something that lets the following pass:

'expose Foo'

import MyThing from './somewhere'
// ...

but continue to fail anything that is not a directive appearing first:

doSomething();

import MyThing from './somewhere'
// ...

I'm happy to take a stab at this if it's something you are interested in. Thanks!

@benmosher
Copy link
Member

Ah, makes sense. Hadn't thought about that before considering modules imply strict mode.

A PR allowing directives (which I guess is defined as an ExpressionStatement containing a string Literal) would be welcome. 😄

@lemonmade
Copy link
Contributor Author

Cool, I can definitely do that. Do you want this as an option or as the default behaviour? Any preference for an option name if you want it as an option?

@benmosher
Copy link
Member

I think it makes sense to always allow directives, until someone says otherwise.

I'm struggling to imagine why you'd want to report pragmas/directives, and if that day comes it's easy to add an option.

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