Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prettier-eslint formatting doesn't work #2840

Closed
4 tasks done
Vorror opened this issue Apr 3, 2021 · 2 comments
Closed
4 tasks done

Prettier-eslint formatting doesn't work #2840

Vorror opened this issue Apr 3, 2021 · 2 comments

Comments

@Vorror
Copy link

Vorror commented Apr 3, 2021

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ
  • I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: MacOs (intel)
  • Vetur version: 0.33.1
  • VS Code version: 1.55.0
  • Node version: 12.18.3

Problem

The "vetur.format.defaultFormatter.js": "prettier-eslint" setting does not work. I've tried this setting at both the workspace level and at the user level.

With a fairly basic eslint config:

module.exports = {
  extends: ['eslint:recommended', 'plugin:vue/recommended'],
  rules: {
    'quote-props': ['error', 'consistent-as-needed']
  },
  parser: 'vue-eslint-parser'
}

This:

const test = {
  'hello-world': 'foo',
  foo: 'bar'
}

Should transform into below when eslint is run:

const test = {
  'hello-world': 'foo',
  "foo": 'bar' // "foo" is now quoted
}

Eslint works correctly when run directly using: ./node_modules/.bin/eslint --fix ./src/Test.vue or using the ESlint: Fix all auto-fixable issues option in VSCode.

The user setting "vetur.useWorkspaceDependencies": true does not affect this issue. I've tried with both this setting on and off.

VLS Logs

[DEBUG] Using prettier. Options
{"singleQuote":true,"semi":false,"trailingComma":"none","printWidth":80,"tabWidth":2,"useTabs":false,"parser":"vue"}
[DEBUG] Using prettier-eslint. Options
{"singleQuote":true,"semi":false,"trailingComma":"none","printWidth":80,"tabWidth":2,"useTabs":false,"parser":"babel"}

As an aside, with "vetur.format.defaultFormatter.js": "prettier-eslint" prettier no longer respects .prettierrc.json file(tested by turning semi:false on and off).

Also, there's nothing special with the quote-props eslint rule. I simply picked a rule that I knew demonstrated the issue.

Reproducible Case

I've created a sample repo here that demonstrates the issue.

@Vorror
Copy link
Author

Vorror commented Apr 3, 2021

After a lot of testing, here's what I found.

The last working version of Vetur is 29.1 w/ prettier-eslint@10.0.0
image

image

If you use a higher version of either, then everything stops working. Here's a link to a working branch of my above repo: https://github.com/Vorror/vetur-prettier-eslint/tree/work-branch

p.s I also had to add babel-eslint but maybe that's normal. Using babel-eslint with Vetur 0.33.1 doesn't fix the issue.

@Vorror Vorror changed the title Prettier-eslint doesn't work Prettier-eslint formatting doesn't work Apr 3, 2021
@arpowers
Copy link

I can confirm that recently I haven't had formatting in component HTML templates working ... this may be the cause.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants