Skip to content
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

Wrong component formatting in .tsx file #1234

Closed
namrastanov opened this issue Jan 31, 2020 · 4 comments
Closed

Wrong component formatting in .tsx file #1234

namrastanov opened this issue Jan 31, 2020 · 4 comments
Labels
locked Please open a new issue and fill out the template instead of commenting.

Comments

@namrastanov
Copy link

namrastanov commented Jan 31, 2020

Prettier - Code formatter 3.20.0

Sometimes it gives me the result as in "Actual result". But after ctral+a + ctrxl+x + ctrl+v it works as "Expected result".

Actual result

export default class MyComponent extends React.Component<
                 MyLongTypeNameProps,
                 MyLongTypeNameState
               > {
                 myProperty1: React.RefObject<HTMLSelectElement>;
                 myProperty2: React.RefObject<HTMLSelectElement>;
                 ...

Expected result

export default class MyComponent extends React.Component<
  MyLongTypeNameProps,
  MyLongTypeNameState
> {
  myProperty1: React.RefObject<HTMLSelectElement>;
  myProperty2: React.RefObject<HTMLSelectElement>;
    ....

Additional information

(http://prntscr.com/qvks05)

VS Code Version: 1.41.0

Prettier Extension Version: 3.20.0

OS and version: Windows 10

Prettier Log Output

["INFO" - 4:14:09 PM] File Info:
{
  "ignored": false,
  "inferredParser": "typescript"
}
["INFO" - 4:14:09 PM] No local configuration (i.e. .prettierrc or .editorconfig) detected, falling back to VS Code configuration
["INFO" - 4:14:09 PM] Prettier Options:
{
  "arrowParens": "avoid",
  "bracketSpacing": true,
  "endOfLine": "auto",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "preserve",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "none",
  "useTabs": false,
  "vueIndentScriptAndStyle": false,
  "filepath": "...",
  "parser": "typescript",
  "rangeEnd": 827,
  "rangeStart": 764
}
["INFO" - 4:14:09 PM] Formatting completed in 227.7758ms.
@ntotten
Copy link
Member

ntotten commented Feb 3, 2020

I am not able to reproduce this issue. Please provide a sample project or detailed steps to reproduce.

@namrastanov
Copy link
Author

namrastanov commented Feb 4, 2020

@ntotten
Try, please, put this text in .ts file. Then ctrl+x line number 8 (with second parameter) and then ctrl+v it again.

interface TypeWithVeryLongLongLongName {
  one: string;
  two: string;
}

export default function MyFunctionNameWithLongText(
  first: TypeWithVeryLongLongLongName,
  second: TypeWithVeryLongLongLongName
) {
  let test = "";
}

Make sure that you switched on formatting on Paste.

@ntotten
Copy link
Member

ntotten commented Feb 4, 2020

Ah, okay. Yeah, this is an issue with the prettier range formatter, not the extension. See prettier/prettier#7148 and prettier/prettier#4926

@ntotten ntotten closed this as completed Feb 4, 2020
@github-actions
Copy link

github-actions bot commented May 4, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label May 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants