paleite / eslint-plugin-diff

Run ESLint on your changes only
https://npm.im/eslint-plugin-diff
MIT License
173 stars 13 forks source link

ESLint Errors/Warnings Not Showing In VS Code #14

Open rushvora opened 3 years ago

rushvora commented 3 years ago

When using the plugin, no warnings show up in the editor at all. The linting does work as expected, but the errors or warnings that show up in the editor disappear completely. I've attached a video of the ESLint errors showing up in VS code when the plugin is not present.

https://user-images.githubusercontent.com/602333/133409716-60d12a17-288a-4b3d-804d-38de64c040be.mp4

paleite commented 2 years ago

thanks for reporting this! looking into it

paleite commented 2 years ago

I think the issue here is that the files are untracked, which means they won’t be linted. I’m working on changing this though, so the plug-in WILL lint untracked files, but in the meantime, you can stage the files you want to lint and it should work. leaving this issue open, since i’m still working on the fix, but should be out this week

rushvora commented 2 years ago

The errors don't show up for the tracked files either. They do show up in the shell when trying to commit, and it works perfectly at that time. Just not in VS Code when editing the file.

paleite commented 2 years ago

I've released a new (alpha) version: https://www.npmjs.com/package/eslint-plugin-diff/v/1.0.13-0 Please try it out and see if that fixes your issues. Untracked files will now be picked up when using plugin:diff/diff.

If it's still not working for you in VSCode, could you please paste your ESLint output? You can copy/paste it from ESLint: Show Output Channel

Thanks in advance!

rushvora commented 2 years ago

1.0.13-0 didn't change anything for me.

The output from ESLint -

[Info  - 11:23:24] ESLint server is starting
[Info  - 11:23:25] ESLint server running in node v14.16.0
[Info  - 11:23:25] ESLint server is running.
[Info  - 11:23:26] ESLint library loaded from: /path-to-folder-here/node_modules/eslint/lib/api.js

Let me know if I can help in any way. I made changes that should throw up linting errors in both tracked and untracked files. The errors get flagged to prevent the commit, but they still don't show up in VS Code.

paleite commented 2 years ago

Hi! Please try https://www.npmjs.com/package/eslint-plugin-diff/v/1.0.13-3

I think the reason we got this bug was because the ESLint plugin for VSCode is a long-running process. I was able to replicate the issue locally and it should be fixed now. Please give it a try and let me know if it works.

Note: because the plugin is using git under the hood, it won’t be able to start showing the linter errors until after you’ve saved your file.

rushvora commented 2 years ago

On initial testing, it doesn't seem to be fixed. 😞 I'll test it out further sometime next week.

rushvora commented 2 years ago

Still no change in behaviour for me 😓 Linting warnings/errors still don't show up in VS Code for changed lines, after the file has been saved.

marmaak commented 2 years ago

Hi @paleite , I tested the latest version (1.0.13-4) but at least on my side the wrong behaviour is still there. I noticed that if I change a line (introducing an error) and then save the file, VSC plugin does not highlight the error. Then if I restart the ESLint server (from VSC) it starts to show the issue on the IDE.

Could it be a cache issue maybe?

maxerbox commented 2 years ago

Same with 1.0.13-4 eslintrc:

{
    "parser": "@typescript-eslint/parser",
    "extends": [
        "plugin:@typescript-eslint/recommended",
        "prettier/@typescript-eslint",
        "plugin:prettier/recommended",
        "plugin:react/recommended", // see https://github.com/jsx-eslint/eslint-plugin-react#configuration. React good practices
        "plugin:diff/diff" // see https://github.com/paleite/eslint-plugin-diff. Lint only changed files.
    ],
    "settings": {
        "react": {
            "version": "16.9"
        }
    },
    "parserOptions": {
        "ecmaVersion": 2018,
        "sourceType": "module"
    },
    "rules": {
        // HACK: one day, enable those rules
        "@typescript-eslint/explicit-member-accessibility": 0,
        "@typescript-eslint/no-explicit-any": 0,
        "@typescript-eslint/explicit-function-return-type": 0,
        "@typescript-eslint/no-unused-vars": 0
    }
}
maxerbox commented 2 years ago

Work now in 1.0.15

marmaak commented 2 years ago

To me it is sill not working. My staging area is empty and VSC shows me linting errors in files that are not touched at all. Same if I change a file introducing some linting issues, save it and the VSC linter does not show me anything.

I can see from VSC logs that the plugin is correctly activated but for some reasons it is not working as it will when we run it from the command line

paleite commented 2 years ago

To me it is sill not working. My staging area is empty and VSC shows me linting errors in files that are not touched at all. Same if I change a file introducing some linting issues, save it and the VSC linter does not show me anything.

I can see from VSC logs that the plugin is correctly activated but for some reasons it is not working as it will when we run it from the command line

@marmaak Which OS are you running? WSL? Which version of the plugin are you running? Could you post some of your logs/output so we can investigate further?

marmaak commented 2 years ago

Sure, sorry if I didn't do this before, my bad:

This is my VSC logs. I started from a clean situation, then I introduced a long line that should be linted (I even tried to save the file).

image

If a turn the plugin off the error appears properly the IDE

maxerbox commented 2 years ago

I can try to debug it if you give a reproducible repo ;)

paleite commented 2 years ago

Yes, if you could provide a repository for us to debug, that would be immensely helpful. Could you create a Codespace on GitHub which reproduces the issue?

And thanks for your patience. I know how frustrating it can be when something doesn't work properly and it's hard to reproduce.

skycrazyk commented 2 years ago

I have the same issue. Eslint plugin for vscode starts highlighting errors if I Restart Extension Host

UPD: But through few seconds it fails again

UPD: In same time eslint-webpack-plugin shows errors correctly

IsLand-x commented 2 years ago

I have the same issue as @skycrazyk 's.

paleite commented 2 years ago

@IsLand-x could you provide me with a reproduction repo, so i can debug it and finally find a fix for this? It's really annoying that it's been an issue for so long. i wanna make sure my plugin works well for you, as well!

IsLand-x commented 2 years ago

@paleite I think i find the bug in the source code. If you're not urgent, I'll try to make a pr to fix it this weekend.

image

The simplest way to fix the bug is NOT to cache the untracked file list when get the processor. Instead, getting untracked file every time preprocess the text. (To get better performance, can cache the file list here) image

IsLand-x commented 2 years ago

I'll provide a minimal reproduction repo late when I arrive home today. I'm still working at company now.

IsLand-x commented 2 years ago

Hey, here's the repo: https://github.com/IsLand-x/eslint-plugin-diff-bug-repoduce

IsLand-x commented 2 years ago

Heres a pr to fix the bug https://github.com/paleite/eslint-plugin-diff/pull/27

paleite commented 2 years ago

Thanks @IsLand-x for debugging and providing a fix!

I've released a pre-release version of it so you can try it out now: npm i eslint-plugin-diff@2.0.2-1

And I'll release a stable version soon

gokulk16 commented 11 months ago

Was trying the new release and the issue is still not fixed.

neilkumar-circle commented 1 week ago

Also seeing this issue in the latest version