phenomnomnominal / betterer

betterer makes it easier to make incremental improvements to your codebase
MIT License
582 stars 39 forks source link

feature(extension): set working directory to nearest parent directory with config #1034

Open diminutivesloop opened 2 years ago

diminutivesloop commented 2 years ago

A project I work on is structured as a mono-repo w/ multiple package directories. Each package has its own separate betterer results and config files. It would be great if the VSCode extension had the option to auto-discover the nearest parent directory with betterer config files and treat that as the working directory for the current file. Alternatively the extension could support setting multiple config and results file locations.

andreialecu commented 1 year ago

I just discovered Betterer and almost had to abandon it because of this issue, but I found a workaround.

I installed @betterer/cli and @betterer/typescript into the root of the monorepo then I added these to .vscode/settings.json

  "betterer.resultsPath": "./subproject-that-needs-checking/.betterer.results",
  "betterer.enable": true,
  "betterer.cachePath": "./subproject-that-needs-checking/.betterer.cache",
  "betterer.configPath": "./subproject-that-needs-checking/.betterer.ts",
  "betterer.debugLogPath": "./subproject-that-needs-checking/.betterer-debug.log"

Seems to work. Luckily I only have one project that needs to be checked by Betterer right now.

andreialecu commented 1 year ago

Here's how the Prettier extension does it:

https://github.com/prettier/prettier-vscode/blob/main/src/ModuleResolver.ts