Closed Keavon closed 2 years ago
Have the same issue .
Weird. Could not reproduce it when upgrading @vue/compiler-sfc
in currect repo.
Could anyone provide a reproduction repo?
Try this one: https://github.com/ferrykranenburgcw/vue-todo-pwa
Use eslint --fix on any .vue
file and it will add 10 blank newlines at the end of the file..
@meteorlxy you should be able to reproduce it with my Graphite project's repo however this is unfortunately not a minimal reproduction and you may need to install some dependencies (like Rust) for the project to compile, but you may be able to get away with not compiling the project and just linting the frontend part of the codebase located in /client/web
. I may or may not have time in the coming week or create a more minimal reproduction repo. The important thing to mention is that it's necessary to delete the node_modules
folder between npm install
s after changing the @vue/compiler-sfc
version in package.json
.
Just an update, I don't seem to be having this problem anymore (with all my dependencies up to date). @ferrykranenburgcw how about you?
@Keavon what versions are you using? I am using versions (an still having this issue): "devDependencies": { "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier-vue": "^3.1.0", "eslint-plugin-vue": "^7.18.0", "prettier": "^2.4.1" }
Having the same issue as well. I believe it might be a Windows only issue? Could not recreate on WSL. Can provide more information if someone else requires.
Some dev dep locked versions if it's useful:
Dev dependencies from package:
"@openapitools/openapi-generator-cli": "^2.4.1",
"@types/body-scroll-lock": "^3.1.0",
"@types/eslint": "^7.28.1",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"@vitejs/plugin-vue": "^1.6.0",
"@vue/compiler-sfc": "^3.2.9",
"@vue/eslint-config-typescript": "^7.0.0",
"autoprefixer": "^10.3.7",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier-vue": "^3.1.0",
"eslint-plugin-vue": "^7.17.0",
"naive-ui": "^2.17.2",
"postcss": "^8.3.11",
"prettier": "^2.3.2",
"tailwindcss": "^2.2.17",
"typescript": "^4.4.2",
"vite": "^2.5.2",
"vite-plugin-eslint": "^1.3.0",
"vue-tsc": "^0.28.4"
}
and .eslintrc.js:
module.exports = {
env: {
node: true,
},
root: true,
extends: [
'plugin:prettier-vue/recommended',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vue/vue3-recommended',
'@vue/typescript/recommended',
'prettier',
],
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2020,
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'prettier-vue/prettier': [
'error',
{
printWidth: 100,
singleQuote: true,
semi: false,
trailingComma: 'es5',
endOfLine: 'auto'
},
],
"linebreak-style": ["error", (process.platform === "win32" ? "windows" : "unix")], // assumes you are using autocrlf
},
// Methods added in vue 3 that are now global and dont require imports
globals:{
defineProps:'readonly',
withDefaults:'readonly',
defineEmits: 'readonly'
}
}
Example SFC:
<script setup lang="ts">
import { computed } from 'vue'
import { useStore } from '@/store'
const store = useStore()
const name = computed(() => store.state.oidc.name)
</script>
<template>
<div>
<p>Hello {{ name }}</p>
</div>
</template>
All line endings are CRLF. Let me know if you need any more information to try and help you recreate it!
Sorry for delay. I'm closing this issue as it seems to be stale. Feel free to report another one with a valid reproduction if the problem still exists.
Let me preface this by saying that I don't know if this is an issue with this Prettier plugin or with
@vue/compiler-sfc
, but the problem is showing up during linting with errors coming fromprettier-vue/prettier
which I believe is this project, so I am posting it here to start. Hopefully with more expertise, it can either be fixed here or filed as an issue with additional information invuejs/vue-next
.Recently I have upgraded my npm dependencies and my lint (
vue-cli-service lint
via thenpm run lint
script) was failing. I have narrowed it down to@vue/compiler-sfc
causing the failure. That is, I successfully upgraded all my other dependencies, even including"vue": "^3.1.4"
and"eslint-plugin-prettier-vue": "^3.1.0"
and the lint error does not happen, until I upgrade"@vue/compiler-sfc": "^3.0.11"
to"@vue/compiler-sfc": "^3.1.0"
(or^3.1.4
, the current version, but the issue starts with the 3.1 series).Here is the commit in my project which downgrades
@vue/compiler-sfc
to fix the problem. Please let me know what else I can provide to help debug this. Below are the logs.CLI log:
Note: the two error lines copy/pasted above don't show the mangled characters viewed in the console, which seem to be printing over each other:
The debug log file referenced in the last line of the above log:
Because the lint command automatically fixes the files, it ends up adding 20 blank lines (with one level of tab indentation) only in the
App.vue
file after the opening<template>
tag, and another 20 blank lines (without any indentation, so actually blank) right before the closing</template>
tag. Below is the file modified by the bugged linter, exactly the same as the original except for the two added blocks of 20 lines, and I have omitted the<style>
and<script>
tags later in the file which were untouched: