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

Avoid clearing Prettier cache when not using prettierrc #303

Merged
merged 1 commit into from
Jun 14, 2020

Commits on Jun 11, 2020

  1. Avoid clearing Prettier cache when not using prettierrc

    At Airbnb we've noticed that the Prettier ESLint rule is extraordinarily
    slow. When running ESLint with `TIMING=1`, Prettier is two orders of
    magnitude slower than our other slowest rules (which come from
    eslint-plugin-import mostly).
    
    I spent some time investigating this today. I ran the Chrome DevTools
    profiler while running ESLint on a directory with 480 files in it.
    Looking at the flame charts, I noticed that this plugin ended up calling
    Prettier's pluginSearchDirs.map.pluginSearchDir for every file that was
    being linted, even though it was being memoized. Through some logging, I
    determined that the Prettier cache was being cleared between every file,
    and narrowed it down to this line, which was added here:
    
      prettier#55 (comment)
    
    It looks like this cache busting was added to make it so long-running
    ESLint processes (e.g. for vscode-eslint) would be able to pick up
    changes to prettierrc files without having to reload the process.
    Thankfully, we don't use a prettierrc file at Airbnb right now, in favor
    of putting our Prettier config inline with our ESLint config. So the
    quick performance fix for us is to simply skip the cache busting when
    this option is not enabled.
    
    In my profiling, this reduces the time spent in ESLint's verifyAndFix
    when running on the same 480 files from 34 seconds to 26 seconds, for a
    total savings of 8 seconds.
    
    For folks who are using prettierrc files, this is still pretty crappy,
    so it would be great to find a better way to do this. Unfortunately my
    knowledge of the inner workings of vscode-eslint and ESLint are not
    enough to know if there might be a better way to do this--e.g. maybe
    there's some ESLint option that we can respect here?
    lencioni committed Jun 11, 2020
    Configuration menu
    Copy the full SHA
    bccbc6c View commit details
    Browse the repository at this point in the history