standard / vscode-standard

VS Code extension for JavaScript Standard Style (`standard`) with automatic fixing
https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard
MIT License
123 stars 24 forks source link

vscode-standard can't find ts-standard module in monorepo #327

Open eettaa opened 2 years ago

eettaa commented 2 years ago

What version of this package are you using? vscode-standard 2.0.1

What operating system, Node.js, and npm version? ubuntu 18.04 LTS node: v14.18.1 npm: 6.14.15

What happened? vscode-standard can't find ts-standard module in monorepo child directory

I have a monorepo project structure and would like to open the TLD in vscode but still have vscode-standard find an appropriate standard engine and tsconfig.json. The structure is:

/personal-path-to-monorepo-mount/monorepo-name
    .git
    /project1
      a.ts
      tsconfig.json
      node_modules/
        ts-standard/
      sub-projectA/
          subA.ts
          tsconfig.json
          node_modules/
              ts-standard/ (?)
    /project2
        b.ts
        tsconfig.json
        node_modules/
            ts-standard/    # I don't have ts-standard installed here but would happily consider doing it if that is part of the solution

I have tried using a multi-root workspace to solve this problem i.e. a monorepo-name/workspace.code-workspace file like:

    "folders": [
        {
            "path": "./"
        },
        {
            "path": "./project1",
            "name": "open nested dir to help vscode-standard find a standard engine (can ignore)"
        }
    ],

Bizarrely, this approach worked great in Aug and early September 2021 but then broke. I can verify that no code/config changed on my side by checking out that version of code. I assume it was related to a vscode-standard of a VS Code version update that changed behavior.

I have also tried a single-rooted workspace with standard.nodePath set to "./project1/node_modules". This does not work at all.

What did you expect to happen?

Are you willing to submit a pull request to fix this bug? If I understand what the specific problem is, I will consider it.

jakepearson commented 2 years ago

Any update on this issue? I have a similar issue where most of my workspace/repo is rust, but we have one directory with typescript that I would like to enable this extension for. The only way I have figured out how to do that is to open the TS folder as a project root in a new window. Would love to not have to do that. Thanks!

mcdado commented 2 years ago

You could set standard.enableGlobally but that means running standard/semistandard from npm -g installation of the packages. Indeed a shortcoming of the extension not being able to use multi-root Workspaces.