Skip to content

linter: no-unused-labels rule doesn't have an AST guard #22396

@connorshea

Description

@connorshea

From running the timings debug mode on the actualbudget repo, I noticed no-unused-labels is called quite often and that seemed wrong:

Rule timings:
Rule                                                      Time (ms)  Relative   Calls  Source
-------------------------------------------------------  ----------  --------  ------  ------
eslint/no-unused-vars                                        62.880     13.8%  833920  native
eslint/no-unreachable                                        25.636      5.6%  833920  native
...
eslint/no-dupe-class-members                                 11.452      2.5%  832197  native
import/default                                               11.443      2.5%  833474  native
eslint/no-unused-labels                                      11.356      2.5%  833920  native
import/no-default-export                                     11.352      2.5%  833407  native

It should be able to only run when a label is detected in the code, which should be incredibly rare.

But we don't actually do anything that checks whether labels exist or that activates the smart codegen logic that would exclude this rule from running on files where it's not relevant: https://github.com/oxc-project/oxc/blob/3b46a8d18782b1028c5c698b5c1bcfcc8b2de9c0/crates/oxc_linter/src/rules/eslint/no_unused_labels.rs

cc: @camchenry we should be able to speed this up by refactoring the code a bit to trigger the proper codegen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions