I am using typescript, prettier and eslint and I'm trying to define a multiline string variable like so:
const text = 'Some really long interesting text' + ' some more really really long text' + ' and some even more really long text'; However, when I run eslint with the fix option, prettier is forcing my code to look like this.
const text = 'Some really long interesting text' + ' some more really long interesting text' + ' and some even more really long text'; I would prefer the + operators to be before the text but I understand that prettier won't let me do that due to it's opinion. Fine. But I don't understand the variable definition starting on the next line. I've never seen the variable definition start on the next line before.
Can anyone help me answer either of these questions:
- Where this came from? I've never seen this standard before and how did Prettier decide to adopt it? The documentation about this is rather bleak.
- Is there anyway I can override it?
Here's my .eslintrc.js:
module.exports = { parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features sourceType: 'module', // Allows for the use of imports }, plugins: ['@typescript-eslint'], extends: [ 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin 'plugin:prettier/recommended', 'prettier/@typescript-eslint', ], rules: { // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs // e.g. "@typescript-eslint/explicit-function-return-type": "off", '@typescript-eslint/ban-ts-comment': 'off' }, }; And here is my .prettierrc.js:
module.exports = { semi: true, trailingComma: "es5", singleQuote: true, printWidth: 120, tabWidth: 4 }; Thank you!
https://stackoverflow.com/questions/65606120/prettier-in-javascript-is-forcing-variable-definition-onto-next-line January 07, 2021 at 11:06AM
没有评论:
发表评论