Skip to content

perf: Switch parser from babel to espree

Lukas 'ai-pi' Eipert requested to merge leipert-add-profiling into main

ci: Expose CPU profile for easier debugging

perf: Switch parser from babel to espree

We used to use babel as our parser for eslint, because we used JavaScript language features which the eslint default parser (espree) didn't support.

As espree is way faster in parsing JS files, and supports all the language features we currently use, this seems like a reasonable step to take. To put numbers to this claim:

  1. GitLab UI, parseForESLint: 5.89s => 2.00s
  2. GitLab, parseForESLint: 3:45 min => 0:50 min

In order to "emulate" the capabilities of babel, we also set parserOptions.ecmaVersion = 'latest'. This means with future eslint / espree updates, we will automatically gain support for parsing newer syntax. Theoretically it could mean, that the supported JS features of babel and eslint diverge in our projects, but that may not be too much of a concern, as:

  1. @babel/eslint-parser might be able to parse things which we do not support in our "compilation chain" anyhow
  2. It is a two-way-door decision because a project could always choose to just switch out the parsers if need-be.

That being said, we made not changes to the assumed global env, and still stick with es2015. You can use a newer env if need-be.

In order to use @babel/eslint-parser again in your project, just install it as a dependency and add the following to your eslint config:

# If you use `vue-eslint-parser`
parserOptions:
  parser: '@babel/eslint-parser'
# If you do not use `vue-eslint-parser`
parser: '@babel/eslint-parser'

BREAKING CHANGE: Switch parser from @babel/eslint-parser to espree

feat: Remove eslint-plugin-babel and @babel/eslint-plugin

We used to use the babel/camelcase rule in the GitLab project in order to enforce camel case inside optional chaining. Now ESLint can parse thise properly.

AFAIK, the only usage of one of a related rule has been removed with: !70 (merged) Neither plugins did enable any rule by default.

BREAKING CHANGE: Remove eslint-plugin-babel dependency BREAKING CHANGE: Remove @babel/eslint-plugin dependency

Edited by Lukas 'ai-pi' Eipert

Merge request reports