gitKrystan / prettier-plugin-ember-template-tag

A prettier plugin for formatting Ember template tags
MIT License
22 stars 12 forks source link

[Bug] VSCode Integration Not Working #40

Closed nlfurniss closed 1 year ago

nlfurniss commented 1 year ago

🐞 Describe the Bug

VSCode is not showing Prettier errors in gjs files, but does in js files

gjs no errors js yes errors

However, the prettier plugin is working, as it can be successfully invoked from the commandline:

nfurniss: bs-proj (master) $ yarn prettier app/components/test.gjs
yarn run v1.22.10
$ code/bs-proj/node_modules/.bin/prettier app/components/test.gjs
app/components/test.gjs
const q
= 123;
= 123;
const q = 123;

<template>
  <Foo />"lol"
</template>
✨  Done in 0.77s.

🔬 Minimal Reproduction

Repro repo: https://github.com/nlfurniss/bs-proj/commit/61a82ea408820c3ddf4d058a282c2287c914c317

😕 Actual Behavior

No red squiggles in VSCode

🤔 Expected Behavior

Red squiggles in VSCode

🌍 Environment

➕ Additional Context

Installed VSCode plugins:

gitKrystan commented 1 year ago

Sounds like you might be running Prettier as a linter rule via ESLint and eslint-plugin-ember. If so, this sounds like https://github.com/ember-cli/eslint-plugin-ember/issues/1659

nlfurniss commented 1 year ago

Oh so is the issue that the error w/using eslint-plugin-prettier w/this plugin throws an error thats silently causing the red squiggles to not show?

I can do Format Document in VSCode just fine (with and without the eslint prettier plugin)

gitKrystan commented 1 year ago

Oh so is the issue that the error w/using eslint-plugin-prettier w/this plugin throws an error thats silently causing the red squiggles to not show?

Most likely this, yes. What happens when you try to run eslint? I would expect one of the issues mentioned in https://github.com/ember-cli/eslint-plugin-ember/issues/1659

I think Format Document uses straight prettier.format(), which works fine.

nlfurniss commented 1 year ago

Oh so is the issue that the error w/using eslint-plugin-prettier w/this plugin throws an error thats silently causing the red squiggles to not show?

Most likely this, yes. What happens when you try to run eslint? I would expect one of the issues mentioned in ember-cli/eslint-plugin-ember#1659

I think Format Document uses straight prettier.format(), which works fine.

Oddly no...

nfurniss: bs-proj (master) $ node_modules/eslint/bin/eslint.js app/components/test.gjs

/Users/nfurniss/code/bs-proj/app/components/test.gjs
  1:7   error  'q' is assigned a value but never used                                                                                                                                                               no-unused-vars
  1:1   error  Replace `⏎` with `·`                                                                                                                                                                                 prettier/prettier
  0:0   error  Replace `__GLIMMER_TEMPLATE(`<Foo·/>"lol"`,·{·strictMode:·true,·scope:·()·=>·({Foo})·})]` with `⏎··__GLIMMER_TEMPLATE(`<Foo·/>"lol"`,·{⏎····strictMode:·true,⏎····scope:·()·=>·({·Foo·}),⏎··}),⏎]⏎`  prettier/prettier
  4:12  error  'Foo' is not defined                                                                                                                                                                                 no-undef
gitKrystan commented 1 year ago

Note that the line:column for the prettier/prettier error when run via eslint is 0:0 which is incorrect. As a result, VSCode doesn't know where to put the squiggly lines. Fixing https://github.com/ember-cli/eslint-plugin-ember/issues/1659 should resolve this issue as well.

gitKrystan commented 1 year ago

Going to close this since it's roughly the same issue with the same solution as https://github.com/gitKrystan/prettier-plugin-ember-template-tag/issues/20