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

local eslint won't work without a sublime-project file #33

Open
coodoo opened this issue Feb 3, 2017 · 2 comments
Open

local eslint won't work without a sublime-project file #33

coodoo opened this issue Feb 3, 2017 · 2 comments

Comments

@coodoo
Copy link

coodoo commented Feb 3, 2017

I've got this config for eslint-formatter in settings > user:

{
  // The location to search for a locally installed eslint package.
  // These are all relative paths to a project's directory.
  // If this is not found, it will try to fallback to a global package
  // (see 'eslint_path' below)
  "local_eslint_path": {
    "windows": "node_modules/eslint/bin/eslint.js",
    "linux": "node_modules/.bin/eslint",
    "osx": "node_modules/.bin/eslint"
  }
}

but seems without a sublime-project file as below, format this view won't work, always complained about eslint binary not found.

Just wondering is a sublime-project file necessary to make it work?

{
	"folders":
	[
		{
			"path": "."
		}
	]
}
@npetruzzelli
Copy link

Are you opening a folder instead of a project? I don't know if you are running into the same thing I did, but I'll share just in case.

For example:

C:\code\project-1\node_modules\
C:\code\project-2\node_modules\
C:\code\project-3\node_modules\

is your top most folder in sublime code or project-#?

Sometimes I have "code" open if I want to reference other projects quickly. Keep in mind, these are not Sublime Projects (directories with a configuration file specific to the SublimeText editor). In this case, it won't work and Sublime will likely give you an error like this:

Error: module.js:487
  throw err;
  ^

Error: Cannot find module
'C:\Users\username\AppData\Roaming\npm\node_modules\eslint\bin\eslint'

... and some stack information. This means it couldn't find the local module, attempted to fall back to the global one and failed. In my case, I don't have it installed globally, so this is expected.

Now, if I open folder with project-# as my top most directory, it works. It appears the local path is relative to the top most directory in the absence of a Sublime Project.

I am not a Python developer, so I can't dig through the code to confirm or deny this, but I don't think this plugin searches ancestor directories from the file being processed to automatically try a local path or try to find a local installation.

@npetruzzelli
Copy link

I'll add that for whatever reason, I don't have this problem with SublimeLinter-eslint. For some reason, it just works. How it locates executables is probably very different from how ESLint-Formatter does it.

http://sublimelinter.readthedocs.io/en/latest/usage.html#how-linter-executables-are-located

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants