Closed SCdF closed 6 years ago
Hi @SCdF !
Proposed fix is at #115 . Please check it! Generally, the problem for unsaved buffers is that we cannot pass in ... well ... a filename, and jshint needs that to find a config automatically. In the PR I pass a fake filename ${folder}/unsaved.js
to jshint. (From reading their code I need to make up a filename not just a starting folder bc they call dirname
on whatever you pass in.)
${folder}
resolves to an open project folder within Sublime. From there it will go up til root for search.
@kaste nice! This works for me, though I only have MacOS to test on.
Does that change make sense. I don't know jshint
well enough, but using a fake file here means it cannot resolve imports etc.
Other options are to just provide a --config
, or to exclude unnamed/unsaved files.
Yeah I guess it depends on the situation. When you create a new file in an existing project it makes sense to be alongside whatever you just had open as a best guess. If that always works even in a completely empty project (ie start sublime without any context and just typing into a new file) then that's ideal!
A typical no-risk-no-fun merge.
To reproduce:
Open up a new ST window. Change the syntax to JavaScript. Type:
Note that the linter complains because you have to use ES6 to use
const
.Now try to fix this with an external
.jshintrc
:Putting this in your home directory doesn't help, and putting one at
/
didn't help either. AFAICT there is no place you can put a default jshintrc file that jshint will actually find when the file is unsaved.Apologies if there is nothing this plugin can do, it's not clear to me if the bug is in jshint, this plugin or sublime-linter in general.