Skip to content

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

@kissu

Description

@kissu

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions