eslint-plugin-prettier: "error Delete `⏎` prettier/prettier" in .vue files
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 (https://github.com/prettier/eslint-plugin-prettier/issues/42) which stated that the issue was resolved over a year ago. Guess it’s back?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (5 by maintainers)
This problem exists and has to do with the newlines inserted.
Take for example this error:
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.If you have this error in another file, just follow the same procedure.
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
I had to restart the local server for it to pick up the change.
@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:I feel very dumb now, but it’s how we learn I guess. Thanks for looking into this!
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.
For other’s reference, I had a similar, but different error.
Caused by this code…
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)
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@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:
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
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:
Thank you for the trick!
@gentunian that did the trick for me ! 👍
@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 runningyarn run lint --fix
get rid of the errors?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