How to prevent Prettier/Vetur from formatting this line:
import { defineComponent, reactive, computed, ref } from 'vue'
to this:
import {
defineComponent,
reactive,
computed,
ref
} from 'vue'
That formatting occurs when the line width exceeds the configured printWidth
(default is 80 characters). I assume your example is just a truncated version of a lengthy line, longer than 80 characters.
Increase printWidth
to avoid the line wrapping:
// .prettierrc.js
module.exports = {
printWidth: 120,
}
If using ESLint+Prettier (in a Vue CLI scaffolded project), configure ESLint's prettier/prettier
options:
// .eslintrc.js
const prettierOptions = require("./prettierrc");
module.exports = {
rules: {
"prettier/prettier": ["error", prettierOptions],
},
};
Be aware that Vetur only supports formatting the full document, so formatting a selected line does not work in SFC <script>
blocks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With