Vscode-eslint: Reload eslint config and clear cache

Created on 29 May 2018  路  29Comments  路  Source: microsoft/vscode-eslint

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.

feature-request help wanted

Most helpful comment

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?)

All 29 comments

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

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

And kill the terminals 馃樋

Valid point.

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

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?)

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!!!).

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.

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

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.

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.

@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.

@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.

@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.

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

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?

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.

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

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.

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

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

cast

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.

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

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

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

is it seriously not implemented yet?

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

@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.

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.

@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.

Was this page helpful?
0 / 5 - 0 ratings