addon-blueprint icon indicating copy to clipboard operation
addon-blueprint copied to clipboard

When generating or upgrading a v2 addon linting is broken in VsCode

Open Mikek2252 opened this issue 9 months ago • 10 comments

Creating or updating a v2 addon with this blueprint gives an error for the linting in VS code. with the following error Parsing error: Cannot find module '@babel/plugin-proposal-decorators'

The error only occurs with ember in vscode, running it with terminal passes.

The command i used was: pnpx ember-cli@latest init -b @embroider/addon-blueprint@latest --pnpm pnpx ember-cli@latest my-addon-name -b @embroider/addon-blueprint@latest --pnpm

plugins being used. ESLint v2.4.4 Prettier ESLint v6.0.0

Mikek2252 avatar May 14 '24 14:05 Mikek2252

what sub-project is throwing the error?

NullVoxPopuli avatar May 14 '24 14:05 NullVoxPopuli

Only on the test app i believe.

Mikek2252 avatar May 14 '24 14:05 Mikek2252

Does the same behavior happen when you do pnpx ember-cli@latest new my-app --pnpm?

NullVoxPopuli avatar May 14 '24 14:05 NullVoxPopuli

No issues when i use that command

Mikek2252 avatar May 14 '24 14:05 Mikek2252

is @babel/plugin-proposal-decorators declared in your test-app's package.json?

NullVoxPopuli avatar May 14 '24 14:05 NullVoxPopuli

Yeah it is "@babel/plugin-proposal-decorators": "^7.24.1",

Mikek2252 avatar May 14 '24 14:05 Mikek2252

What happens if you add that to the root package.json?

NullVoxPopuli avatar May 14 '24 15:05 NullVoxPopuli

That seems to fix it, happy to create a PR to fix it, if that is the correct fix

Mikek2252 avatar May 14 '24 15:05 Mikek2252

I think we probably only need @babel/plugin-syntax-decorators, not the actual transform.

ef4 avatar May 14 '24 15:05 ef4

This also feels like a bug in the VSCode editor extension for eslint :thinking:

NullVoxPopuli avatar May 14 '24 16:05 NullVoxPopuli

FWIW I've seen this issue in several different projects where there's an app or addon that isn't at the project route (monorepo style). Another solution is to define the working directories for eslint in .vscode/settings.json, which would look like this for this particular case:

{
  "eslint.workingDirectories": [
    "./my-addon",
    "./test-app",
  ]
}

I haven't noticed any other impacts of adding this config besides it fixing the issue described at the top of this thread.

fdeters avatar Oct 08 '24 00:10 fdeters

I think this is, in general, resolved.

I generated a new project,

npx ember-cli@latest addon test-eslint --blueprint @embroider/addon-blueprint --pnpm
cd test-eslint

and then opened vscode, typed some gibberish, and got eslint errors image

if anyone is having an issue, let's start a new thread with specifics to your environment.

Thanks all!

NullVoxPopuli avatar Oct 08 '24 00:10 NullVoxPopuli