Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
Prettier doesn't format .tsx file

I've used the Prettier extension in the visual studio code editor for a long time, but recently I am writing to React with Typescript. So I need to configure for Prettier to format .tsx files.

over 4 years ago · Santiago Trujillo
6 Respuestas
Responde la pregunta

0

Create a .vscode folder at the root of your project. In the .vscode folder, create the settings.json file, and in it, write this section:

{
    "[typescript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "[typescriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    }
}

Don't forget to add .vscode in the .gitignore file.

over 4 years ago · Santiago Trujillo Denunciar

0

An easy UI alternative to what has been proposed already:

  1. Search for "default formatter" in your vscode settings.
  2. Click on "Text Editor" and set the default formatter to "Prettier - Code formatter".
  3. Enjoy.
over 4 years ago · Santiago Trujillo Denunciar

0

This will give perfect solution

"Same thing happened to me just now. I set prettier as the Default Formatter in Settings and it started working again. My Default Formatter was null."

https://github.com/microsoft/vscode/issues/108447#issuecomment-706642248

over 4 years ago · Santiago Trujillo Denunciar

0

My Usage

The way I set this up is to use eslint's .eslintrc.json file. First of all, in the "extends" array, I've added

"plugin:@typescript-eslint/recommended"

and

"prettier/@typescript-eslint"

Then, I've set "parser" to "prettier/@typescript-eslint"

Finally, in "plugins" array I've added "@typescript-eslint".

You'll need to grab a couple of NPM packages (install with the -D option):

@typescript-eslint/eslint-plugin
@typescript-eslint/parser

For reference, my entire .eslintrc.json file:

{
  "env": {
    "browser": true,
    "es6": true,
    "jest": true
  },
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "prettier/@typescript-eslint",
    "plugin:prettier/recommended"
  ],
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly"
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "project": "./src/tsconfig.json",
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "plugins": ["react", "@typescript-eslint", "jest"],
  "rules": {
    "react/react-in-jsx-scope": "off"
  }
}

Hope this helps.

over 4 years ago · Santiago Trujillo Denunciar

0

Edit setting with following in settings.json of VScode

"[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
},
over 4 years ago · Santiago Trujillo Denunciar

0

Expanding on iNeelPatel's answer, I had to add two lines to VSCode JSON settings:

"[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
"[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda