pretty-linter
v1.0.5
Published
A script to setup prettier & eslint in your project
Downloads
68
Maintainers
Readme
🚀 pretty-linter
A simple CLI tool to quickly set up Prettier in your project with sensible defaults.
📌 Features
- Automatically configures Prettier with recommended settings.
- Sets up a
.prettierrc.jsonfile. - Creates a
.prettierignorefile. - Adds a
formatscript inpackage.jsonfor easy formatting. - Supports formatting modified files (Git tracked) or all files in a folder or specific file.
- Automatically detects project type:
next,react,vite,nest, ornode.
🛠 Installation
Option 1: Run with npx (Recommended)
npx pretty-linterOption 2: Install Globally
npm install -g pretty-linterThen run:
pretty-linter🚀 Usage
Run the setup command inside your project folder:
npx pretty-linterYou’ll be prompted with options to choose how you want to format files:
1️⃣ Format only modified & newly added files (Git)
2️⃣ Format all files under a folder or a file (you can specify path)
3️⃣ Format only newly added files (Git)You can also run:
npm run formatOr pass a specific path:
npm run format -- [pathName]📁 Framework Detection
This tool automatically detects the project type by reading your package.json. Supported types:
- next → for Next.js projects
- react → for React.js (e.g., CRA or Vite+React)
- vite → for Vite-based apps
- nest → for NestJS backend projects
- node → plain Node.js or backend-only apps
⚙️ Configuration
Only if your project is React-based (Next.js, React, Vite), the following Prettier config will be applied:
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 80,
"tabWidth": 2,
"plugins": [
"@trivago/prettier-plugin-sort-imports"
],
"importOrder": [
"^react(.*)",
"^formik(.*)",
"^redux(.*)",
"^yup(.*)",
"^dayjs(.*)",
"@mui/(.*)",
"@reduxjs/(.*)",
"@/components/(.*)",
"@/types/(.*)",
"@/services/(.*)",
"@/pages/(.*)",
"@/app/(.*)",
"@/features/(.*)",
"@/utils/(.*)",
"@/assets/(.*)",
"@/(.*)",
"@/(.scss)",
"@/(.css)",
"^[./]"
]
}❗ Note:
If the project is Node.js or NestJS, the tool will not include @trivago/prettier-plugin-sort-imports or importOrder settings, since they're not usually relevant in backend-only codebases.
🗂 .prettierignore
These files/folders are ignored by default:
node_modules
dist
build
.next
coverage
*.log✅ Added Script
Automatically added to package.json:
"scripts": {
"format": "npx prettier --config .prettierrc.json --write"
}Run with:
npm run format
# or format a custom folder or file
npm run format -- [pathname]
# example: npm run format -- src/home/index.jsx
🐛 Troubleshooting
Make sure Node.js is installed (
node -v)Clear any broken installations:
rm -rf node_modules && npm installFor peer dependency issues:
npm install --legacy-peer-deps
