don't report errors on empty JavaScript file #767

segrey opened this Issue Dec 7, 2012 · 12 comments


None yet

7 participants

segrey commented Dec 7, 2012

Running JSHint on empty JavaScript file produces "Input is an empty string." error.
This error seems to be confusing, because empty JavaScript file is correct file.

Moreover some project templates (for example HTML5 Boilerplate) contain empty JavaScript files that are supposed to be filled by users with their own logic.
All these files contain "Input is an empty string." errors for the first time.

valueof commented Dec 7, 2012

Empty files are not correct files. You can, by mistake, point JSHint to an incorrect/empty file and without any errors you would think that there are no warnings. Depending on how you use JSHint, why can't you just filter out empty files yourself, before passing them to JSHint?

segrey commented Dec 7, 2012

Thanks for the quick response.
Empty files are executed without errors, that's why I think these files are correct.
Well, it's also possible, by mistake, to point JSHint to an correct nonempty file and there will also be no errors.

We run JSHint from IDE (WebStorm, IntelliJ IDEA and others). So, yes, sure, we can filter out empty files before passing them to JSHint, but in this case console JSHint behavior won't be the same as IDE JSHint one.
It seems to me that errors reported by JSHint in IDE should be the same as errors reported by console JSHint.

segrey commented Dec 11, 2012

Now files that consist of whitespaces only are filtered out by IDE.
IMO the issue is still there for console users.

Skalman commented Dec 11, 2012

Like for other errors, why can't there simply be an option to turn this error off?

valueof commented Jan 13, 2013

I don't understand why can't you just not run JSHint against an empty file?

@valueof valueof closed this Jan 13, 2013
glortho commented Jan 16, 2013

I agree with @segrey. Executing an empty file causes no errors and shouldn't be reported. The reason why it's harder not to run JSHint against an empty file is in the context of a project where you might have a bunch of placeholder files throughout your directory structure, and omitting them in grunt, for example, is a major pain.


This is indeed a pain. I'd love to see a jshint option to ignore empty files for all the reasons @jedverity mention above.


I agree this is a bit of a pain. When running JSHint within Grunt, you want to just point it to your app's JS folder and let it do its thing without having to add and maintain a bunch of exclusions. It might be a bad practice to serve up empty files to the browser, but I fail to see the harm in having them in my dev environment.

But maybe I should be raising this issue to the Grunt team instead of here.

FWIW, I worked around it by placing '//' in my empty files.


I'm doing the same thing with putting empty comments in my files 👎


Have you warmed up to this at all? @antonkovalyov



valueof commented Mar 1, 2013

Okay, fine.

@valueof valueof reopened this Mar 1, 2013
@valueof valueof added a commit that closed this issue Mar 1, 2013
@valueof valueof Don't return an error on empty input.
Lots of people complaining about that so I decided to remove it.
Closes GH-767.
@valueof valueof closed this in ce7da77 Mar 1, 2013
@jugglinmike jugglinmike added a commit to jugglinmike/jshint that referenced this issue Oct 21, 2014
@valueof @jugglinmike valueof + jugglinmike Don't return an error on empty input.
Lots of people complaining about that so I decided to remove it.
Closes GH-767.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment