4

After an hour+ on Google, I can't believe I haven't found any answers or questions to this. I'm using the SublimeLinter-contrib-eslint package in Sublime Text 3. Is there a way to force SublimeLinter to lint a whole project instead of just one file?

I have a semi-large client-side project with a lot of separate files, and obviously, these files share variables across the window. However, by default, SublimeLinter only lints a single file, so it throws errors that '<variable>' is not defined (no-undef) when another file defines it and '<variable>' is defined but never used (no-unused-vars) when other files use it.

In my .eslintrc, I can set these global variables like this:

"globals": {
    "m": true,
    "app": true
},

I could also do this in each file, which is arguably good practice anyway:

var m = m || {};
var app = app || {};

But these methods do not fix the unused variable errors.

The best solution I've come up with is to force SublimeLinter to lint the entire directory rather than the individual file. I can't figure out a way to do this though.

I tried turning on the chdir setting in SublimeLinter's user settings:

{
    "user": {
        ...
        "linters": {
            "eslint": {
                "@disable": false,
                "args": [],
                "excludes": [],
                "chdir": "${project}"
            }
        },
        ...
    }
}

But ^this just sets the $PWD when running eslint, not the arguments passed to eslint.

So is there a way to force SublimeLinter to lint an entire directory (or the whole project)? Is there a better solution to this problem that I haven't thought of? Maybe I'm just spoiled by go fmt.

GreenRaccoon23
  • 3,603
  • 7
  • 32
  • 46

0 Answers0