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

Prettier not working since the latest create-nuxt-app release #9563

Closed
kissu opened this issue Jul 16, 2021 · 6 comments
Closed

Prettier not working since the latest create-nuxt-app release #9563

kissu opened this issue Jul 16, 2021 · 6 comments

Comments

@kissu
Copy link

kissu commented Jul 16, 2021

Versions

  • nuxt: 2.15.7
  • node: 14.15.0

Reproduction

I've created a new Nuxt project with the latest version thanks to npx with the following configuration

image

I could not have a working Prettier with the configuration of the repo.

⚠️ My Prettier formatting was always working through ESlint, and as of today, is working perfectly fine on all the previous projects I've created, prior to the latest create-nuxt-app release.

My initial file to format looks like this

<template>
<div>
  nice
  <Tutorial/>
  </div>
</template>

<script>
export default {
  data() {
    return {
          key: 'test'
    }
  },
}
</script>

How to solve the issue

After some tests, I found the culprit in .eslintrc.js, this is the current configuration generated by the CLI

extends: [
  '@nuxtjs',
  'plugin:nuxt/recommended',
  'prettier'
],

This is the one that do actually work as before

extends: [
  '@nuxtjs',
  'plugin:prettier/recommended', // this line was updated
  'prettier'
],

Then, it formats my file properly

<template>
  <div>
    nice
    <Tutorial />
  </div>
</template>

<script>
export default {
  data() {
    return {
      key: 'test',
    }
  },
}
</script>

I did not hosted it on codesandbox, but the repo can be found on Github.


⚠️ EDIT, my bad: you also need to yarn add -D eslint-plugin-prettier to have it working.

@scscgit
Copy link
Contributor

scscgit commented Jul 28, 2021

fyi, I have a pending PR to replace prettier by plugin:prettier/recommended, I think you shouldn't need to use both together: nuxt/create-nuxt-app#827

@WinterYukky
Copy link

I apologize for any disturbance caused by the PR I created. Please check this comment.
nuxt/create-nuxt-app#827 (comment)

@scscgit
Copy link
Contributor

scscgit commented Aug 25, 2021

Could you please clarify if there is any reason why do you want to use Prettier through ESlint and not directly? As part of my PR I was trying to address a different issue, but it's likely that we'll keep the existing behavior of using only 'prettier' plugin, as it's more standard and recommended by Prettier. We should at least add a lintfix script that includes prettier to the create-nuxt-app template if it won't be covered by eslint's own --fix.

@kissu
Copy link
Author

kissu commented Aug 25, 2021

Here are some advantages of using it directly through ESlint: https://stackoverflow.com/a/68880413/8816585

@stale
Copy link

stale bot commented Apr 27, 2022

Thanks for your contribution to Nuxt!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

@stale stale bot added the stale label Apr 27, 2022
@danielroe danielroe added the 2.x label Jan 18, 2023
@stale stale bot removed the stale label Jan 18, 2023
@danielroe
Copy link
Member

Would you raise this at https://github.com/nuxt/create-nuxt-app/ if it is still relevant? 🙏

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants