Skip to content
  • Lukas 'ai-pi' Eipert's avatar
    perf: Switch parser from babel to espree · b53f2a48
    Lukas 'ai-pi' Eipert authored
    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:
    
    ```yaml
    # 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`
    b53f2a48