Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: n/prefer-node-protocol could use optimization #404

Open
1 task
benmccann opened this issue Jan 7, 2025 · 1 comment
Open
1 task

perf: n/prefer-node-protocol could use optimization #404

benmccann opened this issue Jan 7, 2025 · 1 comment
Labels
bug enhancement rule:update An update to a current rule

Comments

@benmccann
Copy link

Environment

Node version: 22.11
npm version: pnpm 9.15.3
ESLint version: 9.9.1
eslint-plugin-n version: 17.9.0
Operating System: Linux

What rule do you want to report?

n/prefer-node-protocol

Link to Minimal Reproducible Example

https://github.com/sveltejs/svelte

What did you expect to happen?

If I set TIMING=20 while running eslint, I can see that almost half the time linting the Svelte codebase is spent on this rule

Rule                                            | Time (ms) | Relative
:-----------------------------------------------|----------:|--------:
n/prefer-node-protocol                          |   715.705 |    43.9%
no-redeclare                                    |   238.347 |    14.6%
@typescript-eslint/prefer-promise-reject-errors |    88.069 |     5.4%
@typescript-eslint/await-thenable               |    46.862 |     2.9%
svelte/no-unknown-style-directive-property      |    35.708 |     2.2%
no-regex-spaces                                 |    29.598 |     1.8%
@stylistic/quote-props                          |    28.884 |     1.8%
no-global-assign                                |    25.165 |     1.5%
no-misleading-character-class                   |    21.627 |     1.3%
lube/svelte-naming-convention                   |    21.180 |     1.3%
constructor-super                               |    19.286 |     1.2%
no-loss-of-precision                            |    17.931 |     1.1%
no-useless-escape                               |    16.372 |     1.0%
getter-return                                   |    15.868 |     1.0%
no-fallthrough                                  |    15.720 |     1.0%
no-unreachable                                  |    15.522 |     1.0%
no-this-before-super                            |    14.647 |     0.9%
no-control-regex                                |    13.997 |     0.9%
no-dupe-else-if                                 |    12.876 |     0.8%
no-useless-backreference                        |    12.020 |     0.7%

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@benmccann benmccann added the bug label Jan 7, 2025
@scagood scagood added enhancement rule:update An update to a current rule labels Jan 7, 2025
@voxpelli
Copy link
Member

voxpelli commented Jan 7, 2025

I guess some memoization/caching of isEnablingThisRule could help, as it seems to repeat the same version check for every file and doing Denver intersect checks that I guess can be somewhat expensive.

It should at most have to do those checks once for every unique version number.

if (!isEnablingThisRule(context, moduleStyle)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement rule:update An update to a current rule
Projects
None yet
Development

No branches or pull requests

3 participants