-
Notifications
You must be signed in to change notification settings - Fork 342
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
Improve extension in a Multi repository setup with Lerna. #745
Comments
@lukejagodzinski I am pretty sure that eslint in the terminal will fail as well if you execute the command from the workspace root (e.g. the ESLint itself is very sensitive to the current working directory in terms of resolving files. Since it why if in the terminal you have to do a This being said if you can successfully validate in the terminal from the root then please provide me with a GitHub repository I can clone that demos the behavior and I will investigate why it fails in the extension. |
@dbaeumer it work in the root directory because I'm using lerna + yarn workspaces which makes it possible. As I said I can't set |
@dbaeumer ok I've create reproduction repository here https://github.com/lukejagodzinski/vsc-eslint-monorepo-bug.git There is also README file explaining everything and what scripts to run to lint from root and package directory. Let me know what you think about it Btw. Thank you for quick response! :) |
For me that fails the same way whether you validate in the terminal or in VS Code Validating in the right directory works in the terminal and does work in VS Code when setting the working directory. I see the argument that you use lerna to work around the eslint working directory affinity but the extension does have the same limits as eslint itself has. I am open for a pull request to improve the extension in a lerna setup. |
In my real project I have more packages in the {
"eslint.enable": true,
"eslint.packageManager": "yarn",
"eslint.validate": [
"javascript",
"javascriptreact",
{ "language": "typescript", "autoFix": true },
{ "language": "typescriptreact", "autoFix": true }
],
"eslint.workingDirectories": [
{ "directory": "packages/app", "changeProcessCWD": true },
{ "directory": "packages/server", "changeProcessCWD": true }
]
} I don't know why I've assumed that having 2 working directories will fail to detect I've also updated my reproduction to reflect that. I'm actually happy with that. I will just push my Thanks for the help :) EDIT: |
Hi! I have a similar setup. Here’s my story. I think it might be relevant to anyone migrating from TSLint to ESLint. I regularly work on a repo that is a "master repo" to a bunch of micro services. The folder structure looks like this:
In other words, each folder is its own service. They all use TypeScript and TSLint (yes, TSLint – I’ll get back to that), but with slightly different versions and configs. We try to update them to all use the same stuff as we work on different services, but you know, stuff changes all the time. The easiest way to work on this project is to do it from the "master repo". I My experience with the TSLint plugin for VSCode is that it seems to Just Work. Even though I run VSCode from the "master repo" root, where As we all know, TSLint is slowly being deprecated in favor of I think it would make sense to try to beat the TSLint plugin UX-wise! While the TSLint plugin seems to work out of the box (the only difficult thing was to figure out how to enable autofix on save), vscode-eslint has so much stuff that everyone working on the project need to put in their {
"eslint.validate": [
"javascript",
"javascriptreact",
{"language": "typescript", "autoFix": true },
{"language": "typescriptreact", "autoFix": true }
],
"eslint.workingDirectories": [
{ "directory": "./api", "changeProcessCWD": true },
{ "directory": "./serviceA", "changeProcessCWD": true },
{ "directory": "./serviceB", "changeProcessCWD": true },
{ "directory": "./serviceC", "changeProcessCWD": true }
]
} Would it make sense to change how vscode-eslint operates? Currently, it seems to operate on the assumption that all files can be linted from CWD. (The root of the "master repo" in my case.) Wouldn’t it be awesome if the plugin could automatically figure out the correct CWD, I’m not sure if it helps at all, but elm-language-client-vscode seems to work this way. For example, it auto-detects that I have also worked on many projects that have a Off-topic notes if you’re interested in more TSLint->ESLint stories :).eslintrc #446Thanks for reading and thanks for the plugin! |
Hi! Any update about this? I have a similar mono repository structure and the same issue. Updating the 'eslint.workingDirectories' each time a new package is added to the repository is far from an optimal solution. It would be nice if it were possible to configure the eslint vscode extension to automatically detect the location of packages (for example, locate thepackage.json file) and change the working directory to that location. |
The code for supporting glob patterns is is master, but no new version yet. |
There is a new version (Insider testing) that addresses this is two ways:
The version can be found here: #815 |
Now available in 2.0.4. See new auto mode a glob pattern support for working directories. |
Thank you so much for all the improvements available in 2.0.4! 💯 |
I've tried everything to make this work with mono repositories but nothing helps. My eslint config works when run from command line but it fails to work in vsc.
Here is my directories structure:
When I run eslinter from command line everything works perfectly but in the vsc I constantly see error that
tsconfig.json
file can't be found in theweb
directory. It's pretty annoying as it should look for the file in each sub package. It works in eslint cli, so don't know why it doesn't work in vsc.I've also tried changing settings:
and then it works but it's far from perfect as I would like to use something like glob pattern and I can't in the
directory
property. I guess that it would also take the firsttsconfig.json
file that it finds in this directories which doesn't necessary mean the one that is dedicated for a given sub packageThe text was updated successfully, but these errors were encountered: