Search code examples
javascriptvisual-studio-codeprettier

VsCode is creating a new line when i use template literan inside of getElememdById? How can i fix it?


Vscode is creating a new line when I use template literal inside of getElememdById? How can I fix it?

it should be like this:

document.getElementById(`current--${activePlayer}`).textContent = currentScore;

but

    document.getElementById(
      `current--${activePlayer}`
    ).textContent = currentScore;

Solution

  • It won't affect the code functionality,
    However something that worked here was changing the max-len of prettier configs.
    They set default for 80 characteres per line.
    Try using 180 and see if it works.

    Checkout more here in their doc.

    You can change it by setting this option into .eslintrc.json

    .
    .
    .
    "rules": {    
        "max-len": ["error", { "code": 180 }],
         ... // other rules
    }