paleite / eslint-plugin-diff

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

Not working properly with jsdoc and @typescript-eslint plugins #13

Closed johnn-guerrero-aurea closed 2 years ago

johnn-guerrero-aurea commented 3 years ago

Love this library, very useful for linting only modified files.

We are having an issue where modified files are detected, but when this plugin is applied there are some rules skipped.

Configuration without diff plugin

{
  "root": true,
  "plugins": [
    "jsdoc",
    "@typescript-eslint"
  ],
  "parser": "@typescript-eslint/parser",
  "extends": [
    "plugin:jsdoc/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/eslint-recommended"
  ],
  "rules": {
    "jsdoc/require-jsdoc": "error"
  }
}

importTopics.ts file image

Lint Result: image


Configuration with diff plugin

{
  "root": true,
  "plugins": [
    "jsdoc",
    "@typescript-eslint"
  ],
  "parser": "@typescript-eslint/parser",
  "extends": [
    "plugin:jsdoc/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:diff/diff"
  ],
  "rules": {
    "jsdoc/require-jsdoc": "error"
  }
}

importTopics.ts file image

Lint Result: image

Notice that after the plugin is applied we get only one rule violation, others are simply skipped. These are important rules in our process, so to continue using your awesome library we need to have this fixed.

We want ALL rules defined in the 'extends' section to be applied to modified files.

Is there any configuration I could be missing? Or is this an issue with the library working along with these other plugins?

Thanks in advance for your help!

paleite commented 3 years ago

Hi @johnn-guerrero-aurea , thanks for your thorough report!

I think this may be a misunderstanding, but please let me know if I didn't understand properly. You mentioned that you use the plugin to lint modified files, but this plugin is designed to be even more granular; its purpose is to only report modified lines, so any errors outside of the green lines in your screenshot will be omitted by this plugin.

This is useful when you only want to check the code that you've written. E.g. when you lint in a pre-commit hook, only your own errors will prevent the linter from passing.

Another use-case is for when you're introducing new rules, so that code that was considered passing before, will not suddenly make the build break.

johnn-guerrero-aurea commented 3 years ago

@paleite Thanks for your answer.

In the screenshots above, green lines are new code. blue lines are modified code. I would expect the plugin to work with both.

In the examples above, I have modified line 48. So I should be getting the "48:8 JSDoc missing" error and the "48:36 event should be typed" warning.

Is there any configuration missing? Thanks again for your time.

paleite commented 3 years ago

Oh, I think I get it now, but please correct me if I'm wrong:

If so, I agree, that's definitely a bug 🐛 I was unable to reproduce it so far, but if you could provide a reproduction repo, I'd love to take a look at it!

I'll re-open this ticket and mark it as a bug.

Another thing: I notice that the images of importTopics.ts are identical, but I assume the line-results are correct.

paleite commented 3 years ago

And thanks again, @johnn-guerrero-aurea for taking the time to report this. I really appreciate it!

paleite commented 2 years ago

Closing this for inactivity: Can't reproduce