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

Huge performance increase with '<template>': 'espree' #127

Open
freakzlike opened this issue Jan 2, 2025 · 1 comment
Open

Huge performance increase with '<template>': 'espree' #127

freakzlike opened this issue Jan 2, 2025 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@freakzlike
Copy link

freakzlike commented Jan 2, 2025

I was struggling to upgrade ESLint to v9 for a large project, because of massive performance difference with type aware linting.

I've tested the performance only on a sub directory of the project containing only ts and vue lang="ts" files with the following results:

ESLint v8
real    0m42.312s
user    1m10.596s
sys     0m5.044s

ESLint v9
real    1m26.031s
user    1m51.048s
sys     0m5.195s

ESLint v9 after config adjustments
real    0m31.473s
user    0m51.516s
sys     0m3.925s

The biggest performance difference is setting '<template>': 'espree' which made my linting more than 2.5x faster. I'm not sure if these changes break anything, especially as I don't have any vue files with js.

That's my simplified config with the adjustments:

import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'
import * as tseslint from 'typescript-eslint'

export default [
  ...pluginVue.configs['flat/recommended'],
  ...vueTsEslintConfig({
    extends: ['recommendedTypeChecked'],
    // Lead to not existing directory to disable specific settings
    rootDir: './does-not-exist'
  }),
  {
    name: 'vue-typescript/setup',
    files: ['*.vue', '**/*.vue'],
    languageOptions: {
      parserOptions: {
        project: ['**/tsconfig.json', '**/tsconfig.*.json'],
        parser: {
          // Using espree results in "`parseForESLint` from parser `context.languageOptions.parser` is invalid and will just be ignored"
          js: tseslint.parser,
          jsx: tseslint.parser,

          '<template>': 'espree'
        }
      }
    }
  }
]

Perhaps someone can test these changes in their project if there are any problems or other adjustments needed.


Draft PR (#126) with changes in @vue/eslint-config-typescript

@haoqunjiang
Copy link
Member

Yeah, this trick could increase performance, but would also lose the ability to parse or type-check TypeScript in templates. It's a trade-off.

@haoqunjiang haoqunjiang added the documentation Improvements or additions to documentation label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants