eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

Support Lazy Loading Rules

Open mr-sanders opened this issue 8 months ago • 1 comments

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
  ...

mr-sanders avatar Apr 03 '25 22:04 mr-sanders

Sounds good. After looking into it, ESLint core rules are already handling this, but plugins within the ecosystem need to implement Proxy on their own. Also noticed that there's an existing feature request to core, so we can wait for a response on that.

waynzh avatar Apr 11 '25 05:04 waynzh