Skip to content

Support Lazy Loading Rules #2732

Open
Open
@mr-sanders

Description

@mr-sanders

Tell us about your environment

  • ESLint version: 9.22.0
  • eslint-plugin-vue version: 10.0.0
  • Vue version: 2.7.16
  • Node version: 22.14.0

The problem you want to solve.
I would like to run a small subset of fixable stylistic eslint-plugin-vue rules in addition to a Prettier run. The goal is to run only the necessary rules to ensure fast execution, particularly in a Git pre-commit hook. It should also speed up the general linting process agains the rules in shared configurations. This approach should also improve the general linting performance when using shared configurations. Additionally, it would give us the ability to skip loading rules already covered by code formatters.

Your take on the correct solution to problem.
Introduce support for lazy loading of rules, following the example set by the ESLint repository's LazyLoadingRuleMap.

Additional context

Currently, all rules are loaded eagerly, which leads to unnecessary memory usage and slower startup times, especially in configurations using only a subset of rules. Furthermore, the lack of lazy loading interferes with the ESLint core's existing lazy-loading behavior, where core rules are loaded on demand.

ESLint Config

import pluginVue from 'eslint-plugin-vue';

export default [
  ...pluginVue.configs['flat/base'],
];

eslint ./src/App.vue --debug

Expected Result
no eslint core rules are loaded

Actual Result

  ...
  eslint:rules Loading rule 'camelcase' (remaining=289) +0ms
  eslint:rules Loading rule 'dot-notation' (remaining=288) +17ms
  eslint:rules Loading rule 'eqeqeq' (remaining=287) +3ms
  eslint:rules Loading rule 'no-console' (remaining=286) +26ms
  eslint:rules Loading rule 'no-constant-condition' (remaining=285) +1ms
  eslint:rules Loading rule 'no-empty-pattern' (remaining=284) +20ms
  eslint:rules Loading rule 'no-implicit-coercion' (remaining=283) +3ms
  eslint:rules Loading rule 'no-loss-of-precision' (remaining=282) +3ms
  eslint:rules Loading rule 'no-restricted-syntax' (remaining=281) +18ms
  eslint:rules Loading rule 'no-sparse-arrays' (remaining=280) +6ms
  eslint:rules Loading rule 'no-useless-concat' (remaining=279) +24ms
  eslint:rules Loading rule 'object-shorthand' (remaining=278) +11ms
  eslint:rules Loading rule 'prefer-template' (remaining=277) +10ms
  ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions