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

Reload eslint config and clear cache #477

Closed
Akryum opened this issue May 29, 2018 · 38 comments
Closed

Reload eslint config and clear cache #477

Akryum opened this issue May 29, 2018 · 38 comments
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Milestone

Comments

@Akryum
Copy link

Akryum commented May 29, 2018

Is there a way to tell the plugin to reload the configuration and clear the cache?

For example, when using eslint-plugin-graphql and updating the GraphQL schema, errors in the GraphQL queries are still reported based on the old schema.

@Akryum Akryum changed the title Reaload eslint config and clear cache Reload eslint config and clear cache May 29, 2018
@dbaeumer
Copy link
Member

dbaeumer commented May 30, 2018

No this is currently not possible. But you can always reload the Window which will reload the eslint server / plugin.

@dbaeumer dbaeumer added the feature-request Request for new features or functionality label May 30, 2018
@dbaeumer dbaeumer added this to the Backlog milestone May 30, 2018
@Akryum
Copy link
Author

Akryum commented May 30, 2018

But you can always reload the Window which will reload the eslint server / plugin.

And kill the terminals 😿

@dbaeumer
Copy link
Member

Valid point.

@Tbhesswebber
Copy link

Tbhesswebber commented Oct 8, 2018

I have had to refresh my VSCode window every <5 minutes for the past four hours. Well, I didn't know that that restarted the server until someone told me, so I was really closing VSCode entirely for about half of that time. Being able to manually restart the server is probably not valuable in general, but when you're trying to debug why ESLint and other tooling aren't playing nicely together, it would be MAGICAL

@xaviershay
Copy link

But you can always reload the Window

For those who were also wondering what this means/how to do it: Open the command palette ( Ctrl + Shift + P ) and execute Reload Window command (type it in until it autocompletes, press enter). Note that it will reload any terminals (I think it's basically equivalent to closing and re-opening VS Code?)

@parkerault
Copy link

I'll 👍 this feature too; mucking about with your .eslintconfig file is a nightmare if you have to reload VSCode every time you change a rule to see if it works, especially if you have an underpowered computer and lots of extensions (and if your workplace forces the use of shitty antivirus software that make launching VSCode take 30 seconds!!!).

@dbaeumer
Copy link
Member

dbaeumer commented Jul 8, 2019

The extension should handle changes to **/.eslintr{c.js,c.yaml,c.yml,c,c.json} files correctly if located in the workspace. Where is the .eslintconfig located.

@dbaeumer dbaeumer added the help wanted Issues identified as good community contribution opportunities label Jul 8, 2019
@dbaeumer
Copy link
Member

dbaeumer commented Jul 8, 2019

I will accept a PR that add a corresponding command to the extension.

@parkerault
Copy link

parkerault commented Jul 11, 2019

I didn't realize until later that you only have to close and re-open the file. That, and a combination of errors were making me think I had to reload the whole instance. I think the problem is more with the UX around presenting errors in the eslint config for new users. I've been using VSCode for a year and I'm still a little unsure of where to look for the error messages when an extension is not behaving (except for vscode-vim, which tells me an error happened every 30 seconds 😄 ). Perhaps a notification that an eslintrc file was found but can't be loaded because x, y, and z. It might also help to tell the user that a change was detected, but won't be applied until you close and re-open all currently open files. I believe that would stop this particular issue from being commented on.

@futagoza
Copy link

This is really becoming a headache when:

  1. Linting .ts files because the problem now is that when using "include": [ "**/*.ts" ] in my tsconfig.json, the ESLint server will read it and get the current .ts files, but if I add a new .ts file to my project, typescript-eslint will throw an error because it's not in the project files list passed to it at the start (I'm presuming something along this line is what's going on).

  2. Updating eslint config's and/or plugins via npm/yarn install. I keep forgetting to reload the window in this case and mostly remember when I've got some important terminal task running 😢

@dbaeumer Do you mean a command like Reload Window but for the ESLint plugin? If so, it's definitely what I'm looking for.

@dbaeumer
Copy link
Member

@futagoza the *.ts is an interesting case since we should only react to this when validating TypeScript.

For the rest the plugin actually should react and reparse things after changes to the following patterns:

'**/.eslintr{c.js,c.yaml,c.yml,c,c.json}'
'**/.eslintignore'
'**/package.json'

The case that is not covered are arbitrary changes to the node_modules folder. IMO this is fine since usually users run npm install with save or save-dev.

@futagoza
Copy link

@dbaeumer It seems either this isn't the case anymore, or the ESLint plugins aren't being reloaded when there are changes to the .eslintrc* config files (the files are in the root of the workspace).

// .eslintrc*
{

    "extends": "@futagoza",
    "root": true

}

// tsconfig.json
{
    "extends": "@futagoza/tsconfig",
    "include": [ "." ]
}

// src/tsconfig.json
{
    "extends": "@futagoza/tsconfig/node",
    "include": [
        "**/*.ts"
    ],
    "compilerOptions": {
        "outDir": "../out",
        "rootDir": "."
    }
}

Both compiling and linting work fine via the CLI, but vscode-eslint complains every time I create a new file. I've tried modifying the .eslintrc* file and saving, but there's no noticeable change, and I still get the error until I reload the window.

@dbaeumer
Copy link
Member

@futagoza can you provide me with a GitHub repository I can clone that demos this? But as said adding new TS files is currently not handled correctly.

@gwsbhqt
Copy link

gwsbhqt commented Oct 8, 2019

@dbaeumer If you add a new ts file and you get an error, try adding "createDefaultProgram": true in parserOptions

@gwsbhqt
Copy link

gwsbhqt commented Oct 8, 2019

I also encountered the same problem, it seems that eslint will only verify the file when it is reloaded. When I fixed these errors, the old error message still exists. This is very frustrating. Does anyone know of any way to solve this problem?

@BertelBB
Copy link

BertelBB commented Oct 9, 2019

Something is definitely not how it should be, this is happening to me on a daily basis. ESLint starts hanging, showing errors where there are none and auto-formatting stops working. The only thing that works is reloading vscode.

@gwsbhqt
Copy link

gwsbhqt commented Oct 10, 2019

@BertelBB Oh, my God, why is this? I am constantly reloading vscode at least half of my time every day, which is too bad.

@dzintars
Copy link

dzintars commented Jan 9, 2020

Same problem there. I'm glad i find this issue and i no more feel lonely. :) I am on i3 tiling window manager, so my terminals are in another pane so i use CTRL + SHIFT + P > Reload Window while trying to get typescript linting and formatting to work properly in Lerna monorepo.
Kinda PITA
Take my vote for this.

@zacaj
Copy link

zacaj commented Jan 9, 2020

I'm having the same issue as @futagoza. Every time I add a new Typescript file, the ES Lint plugin doesn't pick it up. I get a single error on the first line of code complaining the file isn't in my project. If I run eslint manually via a terminal it works fine. Only way to get the vs code plugin to work again is to reload the window, which is a pain since I sometimes have 5-10 terminals open. While it'd be nice to fix this specific bug, it seems a more general solution of a command (via CTRL+SHIFT+P) to restart the plugin/server somehow would be more generally useful

@dbaeumer
Copy link
Member

Actually this works for me. Can someone provide a GitHub repository I can clone with steps how to reproduce this.

cast

@mb21
Copy link

mb21 commented Jun 10, 2020

We seem to be having this problem after switching git branches on the terminal... it always complains import foobar "does not match the underlying filesystem" afterwards, which is quite annoying. Is this the same issue or a different one? And yes, reloading window fixes it.

@dbaeumer
Copy link
Member

@mb21 sounds like the same issue. A PR with a specific command to reload the server is still welcome :-)

@ecraig12345
Copy link
Member

@dbaeumer Would #845 fix this issue as well, or is some additional step needed to also clear the cache?

@dbaeumer
Copy link
Member

@ecraig12345 good point. I think stopping & restarting the server is the most save thing to do.

@numfin
Copy link

numfin commented Sep 3, 2020

is it seriously not implemented yet?

@rusakovic
Copy link

confirm the issue:
Hot fix for now:
CMD + shift + p and type typescript: Restart TS server or typescript: Reload Project

@leandro-manifesto
Copy link

@rusakovic I'm using ESLint and Typescript-ESLint and that workaround doesn't work, the error just stays there.

But reloading the window works, obviously.

@vdh
Copy link

vdh commented Nov 13, 2020

this plugin has started caching a bad file path somewhere hidden, causing false positive results that the normal CLI does not report, and it's driving me crazy trying to find a way to clear this plugin's cache 😞
This doesn't disappear with a window reload either.

@dbaeumer
Copy link
Member

@vdh a window reload does a hard reload of the ESLint server. So even a command as requested in this issue will not help you.

@dbaeumer dbaeumer modified the milestones: Backlog, 2.1.18, 2.1.17 Mar 10, 2021
@dbaeumer
Copy link
Member

Version 2.1.17 now contains a Restart Server command.

@metasean
Copy link

Of course, to actually use the 2.1.7 update VS Code requires a reload, which is exactly what this ticket's functionality is supposed to avoid. 😩

Regardless, @dbaeumer - thank you for adding the server restart functionality! (It will make life easier in the near future.)

@metasean
Copy link

@dbaeumer - Tangential confused observation, you mentioned the 2.1.17 release, I am able to update to the 2.1.17 in my VS Code, and the package.json indicates the main branch is at version 2.1.17, however when I look at the tagged versions they stop at release/2.1.14 and prerelease/2.1.15-next.1 (i.e. there's no release/2.1.16 or release/2.1.17).

@dbaeumer
Copy link
Member

@metasean thanks for reporting the missing tags. My fault. For the reload on new version install: this is VS Code and nothing the extension can fix by itself.

@dbaeumer
Copy link
Member

I added the tags.

@nick-khoury
Copy link

Deleting the .eslintcache file in my project root directory worked for me.

@0xAl3xH
Copy link

0xAl3xH commented Mar 26, 2021

Version 2.1.17 now contains a Restart Server command.

How do you actually use this command?

@biro456
Copy link

biro456 commented Mar 27, 2021

@al3x-huang Open the Command Palette (by default ctrl + shift + P on Windows) and search for ESLint: Restart ESLint Server.

@mckravchyk
Copy link

+1, it would be very useful when developing an Eslint plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests