Skip to content

"error Delete prettier/prettier" in .vue files #114

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

Closed
ImreC opened this issue Sep 28, 2018 · 19 comments
Closed

"error Delete prettier/prettier" in .vue files #114

ImreC opened this issue Sep 28, 2018 · 19 comments

Comments

@ImreC
Copy link

ImreC commented Sep 28, 2018

I am using the create-nuxt-app to create a nuxt 2.0 application with prettier included. I am running vscode on a windows machine. My package.json looks like this (nothing changed compared to the template):

{
  "name": "test",
  "version": "1.0.0",
  "description": "Test",
  "author": "",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  },
  "dependencies": {
    "cross-env": "^5.2.0",
    "nuxt": "^2.0.0",
    "@nuxtjs/axios": "^5.0.0"
  },
  "devDependencies": {
    "nodemon": "^1.11.0",
    "babel-eslint": "^8.2.1",
    "eslint": "^5.0.1",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-vue": "^4.0.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-plugin-prettier": "2.6.2",
    "prettier": "1.14.3"
  }
}

The error "error Delete prettier/prettier" in .vue files" still persists. I tried to search for a solution, but the only thing that I could find was this old issue (#42) which stated that the issue was resolved over a year ago. Guess it's back?

@ImreC
Copy link
Author

ImreC commented Sep 28, 2018

Updating all related packages does not resolve the issue. package.json now looks like this:

{
  "name": "test",
  "version": "1.0.0",
  "description": "Test",
  "author": "Imre Gelens",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  },
  "dependencies": {
    "cross-env": "^5.2.0",
    "nuxt": "^2.0.0",
    "@nuxtjs/axios": "^5.0.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.1",
    "eslint": "^5.6.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-prettier": "^2.7.0",
    "eslint-plugin-vue": "^4.7.1",
    "nodemon": "^1.11.0",
    "prettier": "^1.14.3"
  }
}

@BPScott
Copy link
Member

BPScott commented Sep 28, 2018

Hi @ImreC, I am not able to reproduce this issue. Can you please provide an example vue file that exhibits this issue or a set of example steps to recreate the issue.

The following steps work for me on a mac. Do they work for you?

yarn create nuxt-app nuxt-app And use the following options:

? Project name nuxt-app
? Project description My prime Nuxt.js project
? Use a custom server framework none
? Use a custom UI framework none
? Choose rendering mode Universal
? Use axios module no
? Use eslint yes
? Use prettier yes
? Author name Ben Scott
? Choose a package manager npm

cd nuxt-app

yarn run lint - Initially reports errors, but should be fixed once nuxt/create-nuxt-app#100 is released

yarn run lint --fix - Fixes errors

yarn run lint - No more errors reported

@dimavolo
Copy link

Same issue here on a fresh setup with create-nuxt-app

? Project name foo
? Project description foobar
? Use a custom server framework Express
? Use a custom UI framework ElementUi
? Choose rendering mode Universal
? Use axios module yes
? Use eslint yes
? Use prettier yes
? Author name Baz
? Choose a package manager npm

@BPScott
Copy link
Member

BPScott commented Sep 30, 2018

Does running yarn run lint --fix cause the errors to be fixed (it does for me)? That create-nuxt-app's default app contains a file that is not formatted to prettier's standard is an issue with create-nuxt-app (as per my prior comment).

This is only an issue with prettier / eslint-plugin-prettier if the issue persists after running running a prettier command that should fix the reported error

@ImreC
Copy link
Author

ImreC commented Oct 1, 2018

@BPScott thanks for looking into this and sorry for not testing this earlier. I tried your solution. It increases the amount of errors from 1 to 4. Error output:

path\to\nuxt\nuxt.config.js
  16:12  error  Replace `⏎······{·rel:·'icon',·type:·'image/x-icon',·href:·'/favicon.ico'·}⏎····` with `{·rel:·'icon',·type:·'image/x-icon',·href:·'/favicon.ico'·}`  prettier/prettier
  29:9   error  Delete `⏎··`                                                                                                                                          prettier/prettier
  35:13  error  Delete `⏎··`                                                                                                                                          prettier/prettier

path\to\nuxt\pages\index.vue
  36:1  error  Delete `⏎`  prettier/prettier

✖ 4 problems (4 errors, 0 warnings)
  4 errors and 0 warnings potentially fixable with the `--fix` option.

@harleytouch
Copy link

harleytouch commented Oct 5, 2018

I had the same issue mentioned in the original post.
The error message appears to be complaining about a line break at line 36 of the pages/index.vue.
So I deleted that line break, restarted the local server and it's all good now.

@BPScott
Copy link
Member

BPScott commented Oct 5, 2018

@BPScott thanks for looking into this and sorry for not testing this earlier. I tried your solution. It increases the amount of errors from 1 to 4. Error output:

Yep that's what I saw to on my initial run of yarn run lint. Does running yarn run lint --fix get rid of the errors?

@ImreC
Copy link
Author

ImreC commented Oct 5, 2018

@BPScott I followed your instructions exactly, but I was using npm. I just found out that npm has a different way of passing arguments to scripts than yarn. On npm it is npm run lint -- --fix. This SO comment captures my sentiment perfectly:

image

I feel very dumb now, but it's how we learn I guess. Thanks for looking into this!

@BPScott BPScott closed this as completed Oct 5, 2018
@BPScott
Copy link
Member

BPScott commented Oct 6, 2018

The -- thing is indeed a headscratcher if you've not came across it before. It's there to so that npm can tell the difference between "pass these args into npm" and "pass these args into the script that npm runs". As you've probably already realized yarn goes the extra mile and passes any unknown flags into the script you're running automatically

@gentunian
Copy link

This problem exists and has to do with the newlines inserted.

Take for example this error:

code/nodejs/nuxt.js/foo/pages/index.vue
  36:1  error  Delete `⏎`  prettier/prettier

Then, go to line 36. You will notice a newline between the style tag and the styles definitions. Remove that line and error is gone.

<style>

.container {

If you have this error in another file, just follow the same procedure.

@microcipcip
Copy link

I have this error but don't have any newline between style and the class and it doesn't go away.

@harleytouch
Copy link

I have this error but don't have any newline between style and the class and it doesn't go away.

I had to restart the local server for it to pick up the change.

@gugacavalieri
Copy link

@gentunian that did the trick for me ! 👍

@AndrianD
Copy link

This problem exists and has to do with the newlines inserted.

Take for example this error:

code/nodejs/nuxt.js/foo/pages/index.vue
  36:1  error  Delete `⏎`  prettier/prettier

Then, go to line 36. You will notice a newline between the style tag and the styles definitions. Remove that line and error is gone.

<style>

.container {

If you have this error in another file, just follow the same procedure.

Thank you for the trick!

@ktiedt
Copy link

ktiedt commented Oct 29, 2018

For other's reference, I had a similar, but different error.

89:1 error Delete ·· prettier/prettier

Caused by this code...

<script>
  export default {

The complaint? export should not be indented, so highlighting the codeblock and removing 1 indent fixed all the errors (17 in total for default.vue)

@njzydark
Copy link

njzydark commented Dec 15, 2018

I have encountered this problem in the template section of the vue file and it has now been resolved. Let's share how I used eslint and perttier in the vue project.

This is my .eslintrc.js

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true
    }
  },
  env: {
    es6: true,
    node: true
  },
  extends: [
    'standard',
    'plugin:vue/recommended',
    'prettier',
    'prettier/standard',
    'prettier/vue'
  ],
  plugins: ['standard', 'vue', 'prettier'],
  rules: {
    'prettier/prettier': [
      'error',
      {
        htmlWhitespaceSensitivity: 'ignore',
        semi: false,
        singleQuote: true
      }
    ],
    'vue/html-self-closing': [
      'error',
      {
        html: {
          void: 'any'
        }
      }
    ],
    'vue/no-use-v-if-with-v-for': ['off'],
    'vue/component-name-in-template-casing': ['off'],
    'vue/no-unused-components': ['off'],
    eqeqeq: ['off'],
    'no-new': ['off']
  }
}

Because I didn't configure the prettierrc file separately, I put the prettier configuration item in the eslint configuration file. The option to solve the error Delete problem is htmlWhitespaceSensitivity: 'ignore'.

This is my vetur and eslint configuration in vscode:

  "prettier.disableLanguages": [],
  "prettier.eslintIntegration": true,
  "eslint.enable": false,
  "eslint.autoFixOnSave": true,
  "eslint.alwaysShowStatus": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    {
      "language": "vue",
      "autoFix": true
    }
  ],
  "vetur.format.defaultFormatter.html": "none",
  "vetur.format.defaultFormatter.css": "none",
  "vetur.format.defaultFormatter.js": "none",
  "vetur.format.defaultFormatter.less": "none",
  "vetur.format.defaultFormatter.postcss": "none",
  "vetur.format.defaultFormatter.scss": "none",
  "vetur.format.defaultFormatter.stylus": "none",
  "vetur.format.defaultFormatter.ts": "none",
  "vetur.validation.template": false,

@jmartinezuk
Copy link

npm run lint -- --fix did it for me

@MuhammadSayedMorsi
Copy link

hi .. i have the same issue with every component i write .. i ask a friend and told me that i should let the last line empty in every file. and it works fine

@BPScott
Copy link
Member

BPScott commented Jan 16, 2019

I'm going to lock this thread as nothing productive is happening. All recent replies have been variations on the theme "Prettier suggested I make a change, I made the change and then prettier was happy"

@prettier prettier locked as resolved and limited conversation to collaborators Jan 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests