gund / eslint-plugin-deprecation

ESLint rule that reports usage of deprecated code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance issues

thany opened this issue · comments

In a rather large project, that unfortunately I'm not at liberty to share, performance of this plugin is a bit dissappointing.

The result of this is not only that it might take a very long time to lint the entire project, but more importantly, in VScode with lint-fixing on save enabled, it will take several seconds for each save action to complete.

I understand it's difficult to get this problem fixed in this particular repository, however, there just might just be a workaround 😎

Inspired on this more generic issue and this preceeding issue, the solution appears to be this piece of VScode configuration:

    "eslint.enable": true,
    "eslint.useESLintClass": true,
    "eslint.codeActionsOnSave.rules": [
        "!deprecation/deprecation",
        "*",
    ],
    "editor.codeActionsOnSave": {
        "source.fixAll": false,
        "source.fixAll.eslint": true
    },

Essentially skipping the deprecation/deprecation rule. This is fine, because the rule only checks code, but doesn't provide fixes, which is exactly the only thing linting on save is good for. The other bits of config are important to get the VScode extension to understand the rules setting in the first place.

Now, I realise that this only fixes it for VScode (well, it does on my machine), so if you enjoy a different editor, you might have to seek out a different solution. However, the above configuration might nudge that search in the right direction. I would not be surprised if eslint plugins for other editors have a similar rules setting to filter certain rules.

And perhaps it's a good idea to list those solutions below, when anyone finds one.

Hey! Thanks for sharing your insights on this!

While there maybe something that slows this rule or perhaps a more optimised way of achieving the same linting I wonder maybe you are running some other actions on save that take longer time (sometimes prettier is the one that is slow).

Looking at this piece of config:

"source.fixAll": false,
"source.fixAll.eslint": true

You are basically disabling all of the fixes and keep only eslint fixes which might point to something else being slow...

Could you please confirm if this is still slow without that setting specified?

I already did that kind of research 😉

VScode is showing a notification in the bottom-right that says Getting code action from "ESLint" so it's quite definitely not another extension that provides fixes on save. This is further confirmed by the fact that I don't even have any other extensions for fixing on save, as far as I'm aware, and the fact that performance was improved when I told it to skip deprecation/deprecation.

Of course, I'm not saying everyone should be adding this config to their editor. It's entirely possible that it heavily depends on the volume and structure of a project, whether or not a performance hit (if any) from deprecation/deprecation is still workable. I was only stating that if you run into ESLint performance problems, this might be an option for you. Or not 😀

Awesome @thany, thanks for confirming this!
Indeed a very good find!

I don't have any experience in debugging eslint rules unfortunately so not quite sure if this is actionable at this point so I might move this issue to discussions instead, unless, of course, if somebody else have an idea how to tackle this 🙂

so I might move this issue to discussions instead

That's fine. I'm not used to discussions being a thing yet, so I go to issues mainly out of habit. Your call 😀

On our fairly large codebase, node OOMs even after 10 gigs of memory.

Problem with performance is also visible when running timing (TIMING=1 npm run lint):

Rule Time (ms) Relative
deprecation/deprecation 5270.079 77.2%
jsdoc/newline-after-description 279.451 4.1%
no-redeclare 268.256 3.9%
@typescript-eslint/naming-convention 181.790 2.7%
id-match 76.086 1.1%
@typescript-eslint/no-empty-function 63.833 0.9%
object-shorthand 63.655 0.9%
no-alert 39.108 0.6%
one-var 38.894 0.6%
@typescript-eslint/no-loss-of-precision 36.527 0.5%

Just a heads up - we've landed a small perf PR in v1.3.3 which may reduce some seconds from your times but don't get too excited as it was a really tiny fix 😁

Thanks! I'm no longer on the same dev team that used this plugin, but I'll consider using it with my new teammates 🙂

Ref typescript-eslint/typescript-eslint#2620 (comment) for some insights into performance.