Skip to content
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

Bug: When "Open Workspace from File" eslint complains that it cannot find imports, when "Open from Folder" the same code, no issues #1847

Open
GeorgeWL opened this issue May 15, 2024 · 5 comments
Labels
info-needed Issue requires more information from poster

Comments

@GeorgeWL
Copy link

GeorgeWL commented May 15, 2024

Bit of an odd error, seems to be related to if the .eslintrc has a parserOptions.project, as when I change from

BROKEN

.eslintrc with relative paths

folders renamed but same structure

"parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
      "generators": true,
      "experimentalObjectRestSpread": true
    },
    // 'project' required for the no-floating-promises rule,
    "project": [
      "./a/tsconfig.json",
      "./b/tsconfig.json",
      "./c/tsconfig.json"
    ]
  },

WORKS

.eslintrc with glob path

folders renamed but same structure

"parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
      "generators": true,
      "experimentalObjectRestSpread": true
    },
    // 'project' required for the no-floating-promises rule,
    "project": [
      "**/tsconfig.json"
    ]
  },
then I no longer see the error, but I'm not sure if that's a bit of a hacky workaround?

vscode Workspace file

repo-name.code-workspace file folders renamed but same structure
{
  "folders": [
    {
      "name": "root folder",
      "path": ".."
    },
    {
      "name": "A",
      "path": "../a"
    },
    {
      "name": "B",
      "path": "../b"
    },
    {
      "name": "C",
      "path": "../c"
    },
    {
      "name": "cypress",
      "path": "../cypress"
    }
  ],
  "settings": {
    "jest.disabledWorkspaceFolders": [
      "root folder",
      "cypress"
    ],
  },
}
@dbaeumer
Copy link
Member

To my knowledge typescript eslint doesn't support glob patterns for projects. If you think they should be supported please file an issue against the typescript eslint repository.

@GeorgeWL
Copy link
Author

GeorgeWL commented May 16, 2024

To my knowledge typescript eslint doesn't support glob patterns for projects. If you think they should be supported please file an issue against the typescript eslint repository.

that's the thing, it only works with the globs, but that feels like a hack.

Maybe I wasn't clear, the first case doesn't work, the second case does.

@GeorgeWL
Copy link
Author

GeorgeWL commented May 16, 2024

the specific error it gives is that if I use "Open Workspace from File" with the relative paths config linked in the issue, then entering any of the JS or TS files in the monorepo gives this error:

Parsing error: Cannot read file 'FILEPATH\a\FOLDER\tsconfig.json'

Even /a/

@dbaeumer
Copy link
Member

Sorry, I misunderstood the issue.

This is really strange since I use relative paths all over my repositories. See https://github.com/microsoft/vscode-eslint/blob/dbaeumer/stale-cuckoo-gold/client/.eslintrc.json#L1

Can you please provide me with a GitHub repository I can clone with a minimal setup that repros what you are seeing.

@dbaeumer dbaeumer reopened this May 17, 2024
@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label May 17, 2024
@GeorgeWL
Copy link
Author

GeorgeWL commented May 17, 2024

No worries about the misunderstanding 🙂 I didn't phrase it particularly well, so it was easy to get confused

my only thought, maybe it's that we include the root folder in there, which includes all the other workspaces, I'm going to see locally if that's true then if it's still an issue I'll get you a minimal setup

edit: seems to not have an effect, I'll get you a repro repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants