mizdra / eslint-interactive

The CLI tool to fix huge number of ESLint errors
MIT License
363 stars 9 forks source link

Create a cache directory under the current directory #227

Closed mizdra closed 1 year ago

mizdra commented 2 years ago

Background

Currently eslint-interactive stores the script files it generates when executing some actions in a cache directory. Currently, this directory is actually a cache directory provided by the OS (ref 1, ref 2).

However, this cache directory is usually outside the current directory where eslint-interactive is executed. This is incompatible with VSCode Workspace Trust and causes action to not function properly.

https://github.com/mizdra/eslint-interactive/blob/363ced52dd0b64129f6c2209a9786f7f4bc074ed/static/example-filter-script.js#L6-L13

Proposal

The proposal is to create a cache directory under the current directory. I am not concerned about the location, but I think that using https://www.npmjs.com/package/find-cache-dir to determine the directory will make the behavior consistent with the tools in the world and less confusing.

find-cache-dir is used by prettier.

Edge case. 1

It may be that in a global installation of eslint-interactive, the cache directory created by find-cache-dir is under $(npm root -g)/.cache/. If this is the case, users with global installations may continue to experience problems with VSCode Workspace Trust.

Edge case. 2

find-cache-dir does not support yarn PnP. Using find-cache-dir may confuse yarn PnP users.

ref: https://github.com/avajs/find-cache-dir/pull/31

mizdra commented 1 year ago

I will not consider yarn PnP and will use find-cache-dir to solve the problem.