A highly opinionated, yet sensible Prettier configuration with built-in support for imports organization, package.json sorting, and JSDoc formatting.
- Built-in Plugins:
prettier-plugin-organize-imports: Automatically sorts and removes unused imports.prettier-plugin-packagejson: Keeps yourpackage.jsonclean and consistently sorted.prettier-plugin-jsdoc: Formats JSDoc comments for better readability.
- Sensible Defaults:
printWidth: 120for modern screens.singleQuote: truefor clean JavaScript/TypeScript.trailingComma: 'all'for cleaner git diffs.- Standardized indentation (2 spaces) and line endings (LF).
- TypeScript Ready: Includes full type definitions for IntelliSense.
- Hybrid Support: Works with both ESM and CommonJS.
# Using npm
npm install --save-dev @eng618/prettier-config prettier
# Using yarn
yarn add --dev @eng618/prettier-config prettier
# Using pnpm
pnpm add --save-dev @eng618/prettier-config prettierTip
All plugins (organize-imports, packagejson, jsdoc) are included as dependencies, so you don't need to install them manually!
The easiest way to use this config is by referencing it in your package.json:
{
"name": "my-cool-project",
"prettier": "@eng618/prettier-config"
}This package ships with a comprehensive .prettierignore file that ignores common non-project directories and build artifacts:
- Build and dist directories (
.next,dist,build,coverage) - Dependency directories (
node_modules,.yarn) - Tooling and cache (
.git,.github,.husky,.cache,.turbo,.eslintcache,.nycrc) - Environment files (
.env*) - OS files (
.DS_Store,Thumbs.db)
Simply copy the .prettierignore file from this package into your project root, or create your own if you need custom patterns.
If you need to override or extend the config, create a prettier.config.js (or .prettierrc.js) file:
import eng618Config from '@eng618/prettier-config';
/** @type {import('prettier').Config} */
export default {
...eng618Config,
// Your overrides here
semi: false,
};const eng618Config = require('@eng618/prettier-config');
/** @type {import('prettier').Config} */
module.exports = {
...eng618Config,
// Your overrides here
semi: false,
};Add these to your package.json for easy formatting:
"scripts": {
"format": "prettier --write .",
"lint:format": "prettier --check ."
}Thanks goes to these wonderful people (emoji key):
Eric Garcia 📖 💻 🚇 |