@halvaradop/prettier-config
v1.2.1
Published
Shared Prettier configuration for all @halvaradop projects.
Maintainers
Readme
@halvaradop/prettier-config
A shareable Prettier configuration for formatting JavaScript, TypeScript, JSON, Markdown, and YAML files across projects. This package ensures consistent formatting and code style throughout your development workflow.
This package is part of the @halvaradop/configs monorepo, providing standardized configurations for various development tools.
Installation
Install the package as a development dependency in your project:
# Using pnpm (recommended)
pnpm add -D @halvaradop/prettier-config
# Using npm
npm install -D @halvaradop/prettier-config
# Using yarn
yarn add -D @halvaradop/prettier-configNote: This package requires Prettier ^2.0.0 as a peer dependency.
Configuration Details
This configuration includes the following settings:
| Setting | Value | Description |
| -------------------- | ------- | ----------------------------------------------- |
| semi | false | No semicolons at the end of statements |
| tabWidth | 4 | 4 spaces for indentation (default) |
| printWidth | 120 | Maximum line length of 120 characters |
| trailingComma | es5 | Add trailing commas based on ES5 standards |
| overrides/tabWidth | 2 | 2 spaces for indentation (json,md,mdx,yaml,yml) |
Usage
Basic Setup
Create a prettier.config.js file in your project root and export the configuration:
import { config } from "@halvaradop/prettier-config"
/** @type {import("prettier").Config} */
export default configAlternative Import Syntax
You can also use the default export directly:
import prettierConfig from "@halvaradop/prettier-config"
/** @type {import("prettier").Config} */
export default prettierConfigCustomization
To extend or override the default configuration:
import { config } from "@halvaradop/prettier-config"
/** @type {import("prettier").Config} */
export default {
...config,
// Override specific options
printWidth: 100,
singleQuote: true,
// Add new overrides
overrides: [
...config.overrides,
{
files: "*.html",
options: {
tabWidth: 2,
},
},
],
}Package.json Configuration
You can also reference the configuration in your package.json:
{
"prettier": "@halvaradop/prettier-config"
}Scripts
Add these scripts to your package.json for easy formatting:
{
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}Related Packages
This package is part of the @halvaradop/configs ecosystem:
@halvaradop/eslint-config- ESLint configuration@halvaradop/tsconfig- TypeScript configuration@halvaradop/tsup- Tsup configuration
License
MIT © Hernan Alvarado
Changelog
See CHANGELOG.md for details about changes in each version.
For more information about Prettier configuration options, visit the official Prettier documentation.
