woldner/VisualLinter

Allow VisualLinter to use executable and config from specified directory

Closed this issue · 9 comments

Installed product versions

  • Visual Studio: 2017 Community.
  • This extension: [1.0.198].

Description

I would like to have VisualLinter run on JavaScript files in one directory whilst referencing the executable and config files from a sibling directory that is not in the ancestry tree of the current directory.

Steps to recreate

  1. Install the eslint package via npm in directory A.
  2. Write some JavaScript in directory B which is a sibling of A.
  3. VisualLinter can not see the executable and config from directory A.

Current behavior

VisualLinter will only use the executable and config from the directory where the file being linted is, or any of its ancestors. But not a sibling, or specified directory.

Expected behavior

It would be nice to be able to provide a directory from where to get the executable and config.

Thank you for the suggestion @sanjsanj

I've thought about this but decided that manually specifying executable/config path from options would not make sense because the options are global, not project specific.

For example imagine that you'd manually set the executable/config path in options when working on project A to path/to/project_a/eslint, next time- when you load up project B the executable/config specified in options (path/to/project_a/eslint) will be used, and don't see it being that useful.

It would basically be the same behavior as the current use global executable/config options, with the added functionality to specify the directory instead of it just being the user home directory, ~/.

I'll go ahead and close this issue- but I encourage others who would like this feature implemented to simply add to this issue by writing a comment.

@jwldnr Thank you for the response. The reason I requested this is because I have a project where there are separate folders for the build tools and linter, and the source code, and they are siblings of each other.

So I need to install eslint in one folder and then have VisualLinter lint files in another parallel folder.
I've managed to edit your source code to hardcode in the folder name and it works great but it poses a minor inconvenience if I want to update to a newer release of yours in the future.

I'm happy either way though, not a problem if you don't have the time. It's an excellent extension and has plugged a big gap in our codebase, really well written as well, thanks!

@sanjsanj I'm really glad to hear you got it working.

I will think about ways to implement this. My initial thought was to add additional folder search options.
Could you show me the folder structure for the project needing this functionality?

@jwldnr Yup sure.

`

  • root\
    • tools\
      • node_modules...\eslint.cmd
      • .eslintrc.js
    • web\
      • scripts\
        • something.js
          `

The folder names are different but this is the structure. I want to lint root\web\scripts\something.js but the executable and config have to live inside of root\tools\ and I get an error in VS2017 because there's no eslint in \web\scripts\ ancestry tree.

@sanjsanj understood. Now I have something to experiment with!

My idea is to- in options be able to specify additional "include directories" when traversing the ancestry tree.
For example, suppose you have the following folder structure:

project-root
├─┬ tools
│ ├── node_modules
│ └── .eslint.js
└─┬ web
  └─┬ scripts
    └── foo.js

and you have specified to include "tools" as additional include directories:

  • when you lint foo.js no config is found, does "tools" directory exist here? no, moving to project-root\web\ directory
  • inside project-root\web\, does "tools" directory exist here? no, moving to project-root\
  • inside project-root\, does "tools" directory exist here? yes, look for executable/config here!

This is all theoretical, and might very well be too general, but I'll report back here if/when I find a solution that make sense to include in the extension.

@jwldnr That would work fine but another option would be just to be able to select a directory and it only looks in there. But hey, whichever way is great!

Can you please include this behaviour for the .eslintignore as well, cheers :)

I've decided to reopen this issue since I'm now actively looking into implementing the feature.
If you're interested, you can track the changes being done in this branch

I've added support for this feature in version 1.0.237.
Please update the extension and report any issues you may find.

PS. Be sure to back up your modified version if this new update somehow break your functionality!

@jwldnr Sweet! Thanks, I'll give it a shot.