Keep code formatting consistent in Replit by adding Prettier and ESLint configuration files to your project root, installing them via Shell, creating an .editorconfig for universal editor settings, and wiring format checks into your .replit run command. This ensures every collaborator writes identically styled code without manual enforcement.
Configure Code Formatting for Team-Wide Consistency in Replit
Inconsistent code formatting creates friction in collaborative projects and makes code reviews harder than they need to be. This tutorial shows you how to set up Prettier, ESLint, and .editorconfig in a Replit project so every team member follows the same style rules automatically. You will configure each tool, create the necessary config files, and connect everything to your run workflow.
Prerequisites
- A Replit account on any plan (Starter, Core, or Pro)
- A JavaScript or TypeScript project in Replit
- Basic familiarity with the Replit workspace and Shell tab
- No prior experience with Prettier, ESLint, or EditorConfig required
Step-by-step guide
Install Prettier and ESLint as dev dependencies
Install Prettier and ESLint as dev dependencies
Open the Shell tab in your Replit workspace (find it in the Tools dock on the left sidebar). Run the npm install command below to add Prettier, ESLint, and the compatibility config that prevents rule conflicts between them. Installing these as devDependencies means they are project-scoped and available to every collaborator who opens the Repl, without polluting the global environment.
1npm install --save-dev prettier eslint eslint-config-prettierExpected result: All three packages install successfully with no errors. You will see them listed under devDependencies in package.json.
Create the .prettierrc configuration file
Create the .prettierrc configuration file
Click the three-dot menu at the top of the file tree, select 'Add file,' and name it .prettierrc. This JSON file defines your project-wide formatting rules. Every developer who works on this Repl will use the same settings automatically. The configuration below enforces single quotes, 2-space indentation, trailing commas, and an 80-character line width, which are the most common conventions in modern JavaScript projects.
1{2 "semi": true,3 "singleQuote": true,4 "tabWidth": 2,5 "trailingComma": "es5",6 "printWidth": 80,7 "bracketSpacing": true,8 "arrowParens": "always",9 "endOfLine": "lf"10}Expected result: A .prettierrc file appears in your project root. Prettier will use these rules for all formatting operations.
Create an .editorconfig file for universal settings
Create an .editorconfig file for universal settings
EditorConfig is a standard supported by most editors and IDEs. While Replit does not natively read .editorconfig, having one in your project root ensures that collaborators who clone the repo into VS Code, Cursor, or other editors maintain the same settings. Create a new file named .editorconfig in the project root and paste the configuration below.
1root = true23[*]4indent_style = space5indent_size = 26end_of_line = lf7charset = utf-88trim_trailing_whitespace = true9insert_final_newline = true1011[*.md]12trim_trailing_whitespace = falseExpected result: An .editorconfig file exists in the project root. Any editor that supports EditorConfig will automatically apply these settings.
Initialize ESLint with a flat configuration
Initialize ESLint with a flat configuration
Create a file named eslint.config.js in your project root. This uses the modern flat config format that ESLint now defaults to. The configuration below sets up recommended rules and integrates eslint-config-prettier to disable any ESLint rules that would conflict with Prettier. This means ESLint handles code quality (unused variables, missing returns) while Prettier handles formatting (indentation, quotes, semicolons).
1import js from '@eslint/js';2import prettierConfig from 'eslint-config-prettier';34export default [5 js.configs.recommended,6 prettierConfig,7 {8 rules: {9 'no-unused-vars': 'warn',10 'no-console': 'warn',11 'prefer-const': 'error',12 },13 },14];Expected result: ESLint is configured to check code quality without conflicting with Prettier formatting rules.
Add format and lint scripts to package.json
Add format and lint scripts to package.json
Open your package.json and add scripts for formatting, linting, and a combined check command. These scripts give you reusable commands you can run from Shell or wire into your .replit configuration. The format:check script is useful for CI-like verification without modifying files.
1{2 "scripts": {3 "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,json}\"",4 "format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,css,json}\"",5 "lint": "eslint src/",6 "lint:fix": "eslint src/ --fix",7 "check": "npm run format:check && npm run lint",8 "start": "node index.js"9 }10}Expected result: Running 'npm run format' in Shell formats all source files. Running 'npm run lint' reports code quality issues.
Wire formatting into the .replit run command
Wire formatting into the .replit run command
Open the .replit file (enable 'Show hidden files' if you cannot see it) and update the run command to format and lint before starting the application. This ensures every time you or a collaborator presses the Run button, the code is automatically formatted and checked. For team projects, this is the single most effective way to enforce consistent style without relying on individual discipline.
1run = "npx prettier --write src/ && npx eslint src/ && node index.js"Expected result: Pressing the Run button now formats code, runs ESLint checks, and then starts the application. Console output shows the formatter and linter results before app startup.
Complete working example
1# .replit configuration with formatting and linting on run23entrypoint = "index.js"4modules = ["nodejs-20:v8-20230920-bd784b9"]56# Format and lint before running the app7run = "npx prettier --write src/ && npx eslint src/ && node index.js"89[nix]10channel = "stable-24_05"1112[deployment]13run = ["sh", "-c", "node index.js"]14build = ["sh", "-c", "npm install && npx prettier --write src/"]15deploymentTarget = "cloudrun"1617[[ports]]18localPort = 300019externalPort = 802021hidden = [".config", "package-lock.json", "node_modules"]Common mistakes when keeping code formatting consistent in Replit
Why it's a problem: Installing Prettier globally instead of as a project devDependency
How to avoid: Use 'npm install --save-dev prettier' so the formatter version is locked to the project and automatically available to every collaborator.
Why it's a problem: Having ESLint formatting rules that conflict with Prettier
How to avoid: Install eslint-config-prettier and add it as the last item in your ESLint config array. This disables all ESLint rules that Prettier already handles.
Why it's a problem: Forgetting to create .prettierignore, causing Prettier to format node_modules
How to avoid: Create a .prettierignore file listing node_modules, dist, build, and any generated files you do not want Prettier to touch.
Why it's a problem: Configuring different indentation in .editorconfig and .prettierrc
How to avoid: Make sure tabWidth in .prettierrc matches indent_size in .editorconfig. Both should use the same value (typically 2 for JavaScript projects).
Best practices
- Always commit .prettierrc, .editorconfig, and eslint.config.js to the project so every collaborator inherits the same rules
- Use eslint-config-prettier to prevent ESLint and Prettier from fighting over formatting rules
- Add a .prettierignore file that excludes node_modules, dist, build, and lock files for faster formatting
- Pin formatter and linter versions in package.json to avoid surprise style changes after updates
- Use the format:check script (--check flag) in deployment builds to catch unformatted code without modifying files
- Keep .editorconfig in sync with .prettierrc to avoid conflicts when collaborators use external editors
- For Python projects, use Black with a pyproject.toml instead of Prettier
- Run formatting before linting in your run command so linters see already-formatted code
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm working in a Replit JavaScript project with a team. How do I set up Prettier, ESLint, and .editorconfig so all collaborators use the same formatting rules? I need config files and a .replit run command that formats automatically.
Set up code formatting for this project. Install Prettier and ESLint as devDependencies. Create a .prettierrc with single quotes, 2-space indentation, and trailing commas. Create an eslint.config.js with eslint-config-prettier. Create an .editorconfig. Update the .replit run command to format and lint before running the app.
Frequently asked questions
No. As of March 2026, Replit does not have a built-in formatting configuration panel. You need to install external formatters like Prettier or Black and configure them via files in your project root.
For projects under 100 source files, Prettier adds less than 2 seconds. For larger projects, add a .prettierignore file and limit formatting to your src directory.
Yes. Prompt Agent v4 with: 'Set up Prettier with single quotes and 2-space indentation, ESLint with eslint-config-prettier, and an .editorconfig. Wire formatting into the run command.' Agent will install packages and create all config files.
Wire the format command into the .replit run command so every collaborator formats code automatically on every run. Additionally, use the format:check script in your deployment build to reject unformatted code before it reaches production.
Use both. Prettier handles formatting (indentation, quotes, semicolons) and ESLint handles code quality (unused variables, unreachable code). Install eslint-config-prettier to prevent rule conflicts.
Install Black via Shell with 'pip install black'. Black enforces a single opinionated style with zero configuration. Add 'black . && python main.py' to your .replit run command.
Replit's built-in editor does not read .editorconfig natively. However, including the file in your project ensures that collaborators who clone the repo into VS Code, Cursor, or other editors maintain consistent settings.
For projects that outgrow simple config files and need advanced CI pipelines with pre-commit hooks and automated formatting checks, the RapidDev team can help you design a scalable development workflow.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation