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
Thoughts on improving performance/effect on vscode pre-commit check. #630
Comments
@sindresorhus @spence-s @fisker - any thoughts? |
XO already does cache, but maybe there's something causing it to invalidate the cache too often. Probably worth looking into. The biggest performance bottleneck in XO is TypeScript and TypeScript ESLint. |
Maybe you could try using |
I am indeed using lint-staged only on changed files. Something that may be a game-changer, which I just recently discovered, are TS project references. I haven't gone down this rabbit hole yet. Talks about running typescript in background, creating .d.ts files as code changes, which are much faster for typescript to parse (instead of the full original source code). This thead is about NX, but it is where the rabbit hole appeared: nrwl/nx#3664 (comment) |
Nothing can be done here that is specific to pre-commits or IDE integration. XO is just a wrapper for ESLint so if (an equivalently-configured) ESLint is slow, so is XO. Basically a duplicate of #515 |
1.) Commit experience inside vscode, when running XO as pre-commit hook
Context:
I am running
xo --fix
with husky+lint-staged in a pre-commit git hook.I also typically use vscode's git sidebar for committing.
I am working on migrating a monorepo from eslint to XO. I'm also updating to latest version of typescript, using tools like ts-migrate, TypeStat, and hopefully TypeWiz, with a sprinkling of my own scripts to cover some edge cases specific to our monorepo.
Poor DX inside vscode.
Due to
xo --fix
being so slow, there are a number of issues that crop up when committing inside vscode. vscode itself could make some improvements here, but the best solution IMO is forxo --fix
to run within about 1-2 seconds for a typical commit. Feel free to skip or skim this section:2.) Solve all issues in 1.)
First, when we save a file inside vscode, we lint it, and then cache something on disk. We store an md5 hash of the file contents, along with the lint errors+warnings for that file. The structure of this cache should match the structure of your actual source code.
This way, for any file we want to lint, we first check the cache. If the file hasn't changed, we just return the cached lint errors+warnings.
This way when user goes to
git commit
, the only thing XO has to do is check the cache. In most cases the vscode/editor extension has already linted files and cached the results. I'd imagine this should be extremely fast.By solving the performance issue, all the edge cases described in 1.) mostly disappear.
The text was updated successfully, but these errors were encountered: