🌐
Reddit
reddit.com › r/reactjs › how do you guys add prettier to vite reactjs project with typescript? (eslint v9)
r/reactjs on Reddit: How do you guys add prettier to vite reactjs project with typescript? (eslint v9)
October 15, 2024 -

Best way to add prettier to default preset given by vite?

import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';

export default tseslint.config(
  { ignores: ['dist'] },
  {
    extends: [js.configs.recommended, ...tseslint.configs.recommended],
    files: ['**/*.{ts,tsx}'],
    languageOptions: {
      ecmaVersion: 2020,
      globals: globals.browser,
    },
    plugins: {
      'react-hooks': reactHooks,
      'react-refresh': reactRefresh,
    },
    rules: {
      ...reactHooks.configs.recommended.rules,
      'react-refresh/only-export-components': [
        'warn',
        { allowConstantExport: true },
      ],
    },
  }
);
Top answer
1 of 5
5
The docs are here: https://prettier.io/docs/en/install.html
2 of 5
4
I may be late, but I found the correct solution, as of now. It's described in the typescript-eslint documentation: https://typescript-eslint.io/users/what-about-formatting#suggested-usage---prettier // import eslint from '@eslint/js'; import someOtherConfig from 'eslint-config-other-configuration-that-enables-formatting-rules'; import prettierConfig from 'eslint-config-prettier'; import tseslint from 'typescript-eslint'; export default tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, ...someOtherConfig, prettierConfig, ); Just pass prettierConfig as an argument after other plugins to tseslint.config. In my case, I added it even after my custom rules because I want prettierConfig to overwrite (disable) all rules from not only other plugins but also from my own rules, as I trust prettierConfig to handle it instead. import globals from 'globals' import js from '@eslint/js' import tseslint from 'typescript-eslint' import prettier from "eslint-config-prettier"; import importPlugin from 'eslint-plugin-import'; import react from 'eslint-plugin-react' import reactHooks from 'eslint-plugin-react-hooks' import reactRefresh from 'eslint-plugin-react-refresh' import reactQuery from '@tanstack/eslint-plugin-query' export default tseslint.config( { ignores: ['dist'] }, { extends: [js.configs.recommended, ...tseslint.configs.recommended, importPlugin.flatConfigs.recommended, react.configs.flat['jsx-runtime'], ...reactQuery.configs['flat/recommended']], files: ['**/*.{ts,tsx}'], languageOptions: { ecmaVersion: 2020, globals: globals.browser, }, plugins: { 'react-hooks': reactHooks, 'react-refresh': reactRefresh, }, settings: { 'import/resolver': { typescript: { alwaysTryTypes: true, extensions: ['.js', '.jsx', '.ts', '.tsx'], }, }, }, rules: { ...reactHooks.configs.recommended.rules, 'react-refresh/only-export-components': [ 'warn', { allowConstantExport: true }, ], "@tanstack/query/exhaustive-deps": "off", // All my custom rules // }, }, prettier, ) I copied the boilerplate from Vite react-ts eslint config, added react query, plugin import, custom rules and prettier. Feel free to copy bits that work for you. if you're going to check, if it works or not, the easiest way I found is: set Eslint rules for semicolons against your prettier rule. In my prettier.json I have "semi": true. So I added 'semi': ['error', 'never'] rule to my eslint.config.js. Then just run from your CLI eslint, e.g. npx eslint and you should see thousands of errors if the prettier config didn't apply. If it did, no new errors will show. Don't forget to remove the eslint "semi" testing rule afterwards!
🌐
Vue School
vueschool.io › home › news › eslint and prettier with vite and vue.js 3
ESLint and Prettier with Vite and Vue.js 3 - Vue School Articles
July 28, 2025 - Set up ESLint and Prettier with Vite and Vue.js 3 for clean, consistent code. Learn how to integrate vite-plugin-eslint in Vue Apps.
🌐
DEV Community
dev.to › leon740 › setup-eslint-prettier-husky-with-vite-860
Setup ESLint, Prettier, Husky with Vite - DEV Community
November 15, 2024 - yarn add -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh eslint-plugin-import eslint-import-resolver-typescript eslint-plugin-jsx-a11y eslint-config-prettier eslint-plugin-prettier prettier · { "name": "app", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", "preview": "vite preview" }, "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1" }, "devDependencies": { "@eslint/js": "^9.13.0", "@types/react": "^18
🌐
DEV Community
dev.to › marcosdiasdev › adding-eslint-and-prettier-to-a-vitejs-react-project-2kkj
Adding ESLint and Prettier to a ViteJS React project - DEV Community
March 21, 2023 - Recently, I decided to try ViteJS as an alternative to Create React App. Although ViteJS already offers a basic template for React applications it doesn't come shipped with ESLint and Prettier.
🌐
GitHub
github.com › winniesi › vite-eslint
GitHub - winniesi/vite-eslint: My ⚡️Vite configuration, including ESLint, Prettier and Tailwind CSS
Make modifications to .eslintrc.js (if not, create one): { "extends": [ "some-other-config-you-use", "prettier" ] }
Author   winniesi
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-set-up-vite-with-eslint-and-prettier
How to Set Up Vite with ESLint and Prettier? - GeeksforGeeks
September 11, 2024 - Integrating ESLint and Prettier is important to maintaining consistent code quality and style across a Vite project. Prettier ensures uniform code formatting, while ESLint assists in locating and resolving possible coding errors.
🌐
GitHub
github.com › TheSwordBreaker › vite-reactts-eslint-prettier
GitHub - TheSwordBreaker/vite-reactts-eslint-prettier: vite-react-typescript with eslint and prettier predefined settings · GitHub
A starter for React with Typescript with the fast Vite and all static code testing with Eslint and formatting with Prettier.
Author   TheSwordBreaker
Find elsewhere
🌐
DEV Community
dev.to › topeogunleye › building-a-modern-react-app-with-vite-eslint-and-prettier-in-vscode-13fj
Supercharge Your React Development with Vite, ESLint, and Prettier in VSCode - DEV Community
July 30, 2024 - Boost your React projects by combining Vite’s fast development server, ESLint’s strong linting features, and Prettier’s consistent formatting. With these tools, your VSCode becomes a productivity powerhouse.
🌐
JavaScript in Plain English
javascript.plainenglish.io › setting-up-eslint-and-prettier-in-a-react-19-project-with-vite-using-eslint-9-326147501971
Setting Up ESLint and Prettier in a React 19 Project with Vite (Using ESLint 9) | by Leandro A. Siqueira | JavaScript in Plain English
October 21, 2025 - In this guide, we’ll walk through setting up ESLint 9 (Flat Config) and Prettier in a React 19 + Vite project — and we’ll go one step further by adding Husky and lint-staged to automate these checks before every commit.
🌐
GitHub
github.com › pappijx › Vite-react-eslint-prettier-husky-setup
GitHub - pappijx/Vite-react-eslint-prettier-husky-setup: Effortlessly Setting up Your React Project with Vite, Husky, TypeScript, and ESLint: A Comprehensive Guide
This blog post provides a step-by-step guide to set up a React project using Vite, Husky, TypeScript, and ESLint.
Starred by 25 users
Forked by 4 users
Languages   CSS 51.8% | JavaScript 21.0% | TypeScript 15.0% | HTML 10.5% | Shell 1.7%
🌐
Prettier
prettier.io › docs › install
Install · Prettier
Use eslint-config-prettier to make Prettier and ESLint play nice together.
🌐
Stackademic
stackademic.com › blog › adding-eslint-and-prettier-to-a-vitejs-react-project
Adding ESLint and Prettier to a ViteJS React project | Stackademic
August 12, 2023 - Recently, I decided to try ViteJS as an alternative to Create React App. Although ViteJS already offers a basic template for React applications it doesn’t come shipped with ESLint and Prettier.
🌐
Medium
medium.com › @nedopaka › setup-a-react-vite-project-with-prettier-vitest-2024-12e291669b4b
Setup a React Vite project with Prettier & Vitest [2024] | by Sasha Nedopaka | Medium
February 1, 2024 - Keep in mind, that you should have installed ESLint plugin to make it work. ... Looking on package.json it has come to my attention that there are 2 packages with type declarations, although we do not use TypeScript in our project. Let’s get rid of them with npm rm command. ... Now let’s install Prettier to make our code look nice.
🌐
Medium
medium.com › @contactmanoharbatra › eslint-and-prettier-configuration-f0259ebeb58b
Eslint and Prettier configuration | by Manohar Batra | Medium
September 10, 2025 - Eslint and Prettier configuration YouTube: https://www.youtube.com/@RoadToCodeWithMB 🔧 Step 1: Install ESLint and Plugins In your Vite React project root, run: (sometimes it comes by default when …
🌐
Prettier
prettier.io › docs › integrating-with-linters.html
Integrating with Linters · Prettier
Most stylistic rules are unnecessary when using Prettier, but worse – they might conflict with Prettier! Use Prettier for code formatting concerns, and linters for code-quality concerns, as outlined in Prettier vs.
🌐
DEV Community
dev.to › marina_eremina › how-to-set-up-eslint-and-prettier-for-react-app-in-vscode-2025-2341
How to Set Up ESLint and Prettier for React app in VSCode (2025) - DEV Community
July 8, 2025 - ESLint helps to catch bugs and enforce consistent code quality. Prettier ensures consistent code formatting by automatically applying style rules. ✅ Ensure both extensions are enabled after installation. Use Vite’s react-ts template to start a new project:
🌐
Codeomelet
codeomelet.com › posts › react-prettier-eslint-configuration
React Prettier Eslint Configuration | CodeOmelet
If you are following along with CodeOmelet posts, Prettier configuration has already been seen and covered along with Angular, in this Angular Prettier ESLint Configuration article, we will follow the same tone. Previously in React ESLint Configuration, we have seen how to configure ESLint with React Vite app, which will be helpful to continue the inclusion of Prettier as ESLint rule.
🌐
DEV Community
dev.to › khalid7487 › configure-eslint-prettier-and-show-eslint-warning-into-running-console-vite-react-typescript-project-pk5
Configure Eslint, Prettier and show eslint warning into running console vite react typescript project - DEV Community
June 8, 2024 - Assuming you already have your React Vite project set up (using npm create vite@latest), the first step is to install Vitest: yarn add eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint-plugin-react-refresh prettier typescript-eslint