You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
restart linting if .lintr file is created or modified #354
linting is called by languageserver. You could always save your file to trigger linting if .lintr is changed. It will always use the latest rules defined in the .lintr.
@renkun-ken appreciate the feedback! Any idea where I can configure the “re-lint on .lintr save” setting?
Also, appears that languageserver isn’t honoring the exclusions in my .lintr file. Not sure how to repro that behavior in a way that’s helpful, but wondering how I could debug that?
Any idea where I can configure the “re-lint on .lintr save” setting?
Maybe I'm not saying it clearly. There's no "re-lint on .lintr save" but "re-lint on file save with latest .lintr. If you change your .lintr, you could always save your file being edited to trigger the linting and it will use the latest .lintr without having to restart.
appears that languageserver isn’t honoring the exclusions in my .lintr file.
languageserver calls lintr::lint_text in a separate process to perform the diagnostics and languageserver does not read your .lintr file but passes the file path to lintr and only the lintr package will read it.
Looks like your .lintr is not written correctly. You may use lintr::lint_file("path/to/your/script.R") and see if the linting is producing expected results.
A correct .lintr file to exclude some linters looks like the following:
okay, so did some more playing around here with respect to diagnostics honoring the exclusions property in .lintr.
I was able to confirm that find_config("path/to/my/script") does find and recognize that the project .lintr file. Furthermore, with a opening of the project, it appears language-server does honor the exclusions in .lintr, which I've left below for reference.
Not sure if you want to leave this issue open to add the "on-save" feature still, seems like it'd be a hook on the workspaceonDidSaveTextDocument event or potentially the onDidSaveConfiguration event.
The exclusions not working is caused by languageserver trying to lint a temporary file (with user edits saved) rather than the real file in user workspace folder. The path in exclusions applies to the workspace folder but not the temp folder.
To resolve this more easily, we filed an issue r-lib/lintr#475 but no action is taken yet. And this is indeed another issue of languageserver. Would you mind posting an issue about not respecting exclusions property in .lintr on langugeserver side and link back to this one?
linting is called by languageserver. You could always save your file to trigger linting if .lintr is changed. It will always use the latest rules defined in the .lintr.
I'm saving the file but the old linting rules are still applied
Activity
renkun-ken commentedon Jun 7, 2020
linting is called by languageserver. You could always save your file to trigger linting if .lintr is changed. It will always use the latest rules defined in the
.lintr.alex-gable commentedon Jun 14, 2020
@renkun-ken appreciate the feedback! Any idea where I can configure the “re-lint on .lintr save” setting?
Also, appears that languageserver isn’t honoring the exclusions in my .lintr file. Not sure how to repro that behavior in a way that’s helpful, but wondering how I could debug that?
renkun-ken commentedon Jun 15, 2020
Maybe I'm not saying it clearly. There's no "re-lint on .lintr save" but "re-lint on file save with latest
.lintr. If you change your.lintr, you could always save your file being edited to trigger the linting and it will use the latest.lintrwithout having to restart.languageserver calls
lintr::lint_textin a separate process to perform the diagnostics and languageserver does not read your.lintrfile but passes the file path tolintrand only thelintrpackage will read it.Looks like your
.lintris not written correctly. You may uselintr::lint_file("path/to/your/script.R")and see if the linting is producing expected results.A correct
.lintrfile to exclude some linters looks like the following:alex-gable commentedon Jun 20, 2020
okay, so did some more playing around here with respect to diagnostics honoring the
exclusionsproperty in.lintr.I was able to confirm that
find_config("path/to/my/script")does find and recognize that the project.lintrfile. Furthermore, with a opening of the project, it appears language-server does honor theexclusionsin.lintr, which I've left below for reference.once I open the file, however, it begins linting the file, even though it's in the
exclusionslist that language-server formerly honored.That all being said, it:
languageserverNot sure if you want to leave this issue open to add the "on-save" feature still, seems like it'd be a hook on the workspace
onDidSaveTextDocumentevent or potentially theonDidSaveConfigurationevent.renkun-ken commentedon Jun 20, 2020
Thanks for your testing.
The
exclusionsnot working is caused by languageserver trying to lint a temporary file (with user edits saved) rather than the real file in user workspace folder. The path inexclusionsapplies to the workspace folder but not the temp folder.To resolve this more easily, we filed an issue r-lib/lintr#475 but no action is taken yet. And this is indeed another issue of languageserver. Would you mind posting an issue about not respecting
exclusionsproperty in.lintron langugeserver side and link back to this one?renkun-ken commentedon Jun 27, 2021
Closing as resolved.
raffaelemancuso commentedon Jul 24, 2025
I'm saving the file but the old linting rules are still applied
raffaelemancuso commentedon Jul 25, 2025
Found the solution.
You have to reload the window with
ctrl+shift+P->Developer: Reload Window.See https://stackoverflow.com/a/79625871/1719931.