astrocommunity icon indicating copy to clipboard operation
astrocommunity copied to clipboard

Typescript Pack ( root_has_file ) issues with Superproject and Submodule Architecture

Open belafonte opened this issue 2 years ago • 13 comments

Checklist

  • [X] I have searched through the AstroNvim docs
  • [X] I have searched through the existing issues of AstroNvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.1

Operating system/version

macos 13.5.2

Terminal/GUI

kitty

Describe the bug

Hello There,

When having a "Superproject" with several Submodules, the root_has_file seems to resolve the root directory of the Superproject which might not even be a Nodejs/Js Project.

So in this case Prettier or Eslint only work when defined in the package.json, since they are resolved relative to the current working directory.

Why is resolving of the eslint and prettier config implemented different for package.json and config files? Wouldn't it make sense to resolve them relative to the cwd as well?

Steps to Reproduce

mkdir test_ts_pack cd test_ts_pack/ mkdir inner cd inner npx create-next-app@latest nvim .

Expected behavior

eslint_d will not start

adding config to eslintConfig prop in package.json will start eslint_d

Screenshots

No response

Additional Context

No response

belafonte avatar Sep 28 '23 07:09 belafonte

also having this issue, have u found any workaround?

nochzato avatar Sep 28 '23 17:09 nochzato

I think for now the only way is to use the package.json properties, since package.json is referenced relative to the cwd. Or configure everything manually and avoid using the ts pack, basically copy and paste their config and dont use root_has_file function.

belafonte avatar Sep 28 '23 17:09 belafonte

@Uzaaft wdyt?

NesterenkoDanil avatar Oct 02 '23 11:10 NesterenkoDanil

sorry about the silence, been a stressful week. I'll have to take a look at the issue more closely, especially the original PR before I comment on the issue here.

Uzaaft avatar Oct 02 '23 13:10 Uzaaft

Could we get a more real life example? I feel like the example given is "too far fetched". I can't see the utility of it. This might not actually be an issue that's due to how eslint/prettier is setup, but it could also have something to do with how the root folder is detected for the project outside of the methods used in the community plygin(using .git folder, or other files)

Uzaaft avatar Oct 08 '23 11:10 Uzaaft

This is coming from a real life example...

It is common sense to have submodules in a project. Submodules are git repos. Ergo this does not work with submodules that use prettier or eslint.

And i would imagine that Monorepos would fail either.

My example was just a very simplified version of that, to reproduce the issue.

belafonte avatar Oct 08 '23 11:10 belafonte

This is coming from a real life example...

It is common sense to have submodules in a project. Submodules are git repos. Ergo this does not work with submodules that use prettier or eslint.

And i would imagine that Monorepos would fail either.

My example was just a very simplified version of that, to reproduce the issue.

Most of my projects are monorepos. I used to use the community pack with those and I never had an issue, and the pack has changed minimally since then.

Do you have a github repo with the submodule architecture you've described I can test on?

Uzaaft avatar Oct 08 '23 13:10 Uzaaft

Yes, here the repo where it fails: https://github.com/leihs/leihs

the procure submodule is the npm project

belafonte avatar Oct 10 '23 07:10 belafonte

Ah now I get the issue. A new PR with vscode-eslint-lsp solves the eslint side of this problem.

Uzaaft avatar Oct 10 '23 15:10 Uzaaft

For prettier, we need to figure that out...

Uzaaft avatar Oct 10 '23 15:10 Uzaaft

@belafonte @NesterenkoDanil @nochzato Does #600 solve the issue at the eslint side?

Uzaaft avatar Oct 10 '23 16:10 Uzaaft

Sorry for replying late... Had no chance to test it earlier. But yes i can confirm, that eslint does work now!

Great thank you.

belafonte avatar Oct 22 '23 16:10 belafonte

No worries. Now we only need to fix prettier...

Uzaaft avatar Oct 22 '23 17:10 Uzaaft

Newest commit should've fixed this.

Uzaaft avatar May 14 '24 06:05 Uzaaft

Let me know if this is still an issue and I can reopen, but should be resolved now!

mehalter avatar May 14 '24 20:05 mehalter