
Company News
Jerod Santo Joins Socket as Head of Media
Allow myself to introduce... myself.
@kjanat/prettier-config
Advanced tools
My personal Prettier config with support for XML/SVG, Tailwind CSS, and package.json formatting
A comprehensive, shareable Prettier configuration with built-in support for XML, Tailwind CSS, and package.json formatting. Works seamlessly with Bun, Node.js, CommonJS, ES Modules, and TypeScript projects.
bun add -D @kjanat/prettier-config prettier
npm install --save-dev @kjanat/prettier-config prettier
yarn add --dev @kjanat/prettier-config prettier
pnpm add -D @kjanat/prettier-config prettier
Add to your package.json:
{ "prettier": "@kjanat/prettier-config" }
Or create a .prettierrc file:
"@kjanat/prettier-config"
import prettierConfig from "@kjanat/prettier-config";
/**
* @type {import("prettier").Config}
*/
const config = {
...prettierConfig,
// Your overrides here
semi: false,
printWidth: 100,
};
export default config;
const prettierConfig = require("@kjanat/prettier-config");
/**
* @type {import("prettier").Config}
*/
module.exports = {
...prettierConfig,
// Your overrides here
semi: false,
printWidth: 100,
};
import type { Config } from "prettier";
import prettierConfig from "@kjanat/prettier-config";
const config: Config = {
...prettierConfig,
// Your overrides here with full type safety
semi: false,
printWidth: 100,
} satisfies Config;
export default config;
{
// Extend the base configuration
"prettier": "@kjanat/prettier-config",
// Add your overrides
"semi": false,
"printWidth": 100,
}
This configuration includes the following Prettier plugins:
{
// Tailwind CSS functions
tailwindFunctions: ["cn", "clsx", "tw"],
// Object formatting
objectWrap: "collapse",
// Experimental features
experimentalTernaries: true,
// File-specific overrides
overrides: [
// CSS files use tabs
{ files: ["*.css"], options: { useTabs: true } },
// JSON with comments
{ files: ["*.jsonc"], options: { parser: "json", trailingComma: "none", useTabs: true } },
// YAML files
{ files: ["*.yaml", "*.yml"], options: { singleQuote: false } },
// XML and SVG files
{
files: ["*.xml", "*.svg"],
options: {
parser: "xml",
useTabs: true,
bracketSameLine: false,
singleAttributePerLine: true,
xmlSortAttributesByKey: true
}
},
// HTML files
{ files: ["*.html"], options: { useTabs: true, xmlWhitespaceSensitivity: "ignore" } }
]
}
The configuration includes support for common Tailwind CSS utility functions:
cn() - Common className utilityclsx() - Conditional classestw() - Tagged template literalsTo add more functions, extend the configuration:
import prettierConfig from "@kjanat/prettier-config";
export default {
...prettierConfig,
tailwindFunctions: [...prettierConfig.tailwindFunctions, "myCustomFunction"],
};
// Native ESM import
import prettierConfig from "@kjanat/prettier-config";
// Dynamic import
const prettierConfig = await import("@kjanat/prettier-config");
// CommonJS require
const prettierConfig = require("@kjanat/prettier-config");
// Full type safety with TypeScript
import type { Config } from "prettier";
import prettierConfig from "@kjanat/prettier-config";
// Config is fully typed
const myConfig: Config = prettierConfig;
Works out of the box with:
| Environment | Version | Support |
|---|---|---|
| Bun | ≥1.0.0 | ✅ Full |
| Node.js | ≥18.0.0 | ✅ Full |
| Node.js | 16.x | ⚠️ Works but not tested |
| Deno | Latest | ✅ Via npm: specifier |
| Browser | Modern | ✅ Via bundler |
| Module System | File Extension | Support |
|---|---|---|
| ES Modules | .mjs, .js | ✅ Full |
| CommonJS | .cjs, .js | ✅ Full |
| TypeScript | .ts, .mts, .cts | ✅ Full with types |
# Build the package
bun run build
# Run type checking
bun run lint
# Format code
bun run format
# Check formatting
bun run format:check
# Clean build artifacts
bun run clean
# Run tests
bun test
# Check package exports
bun run test:exports
# Full build with validation
bun run build:check
Install the package:
bun add -D @kjanat/prettier-config
Replace your .prettierrc content:
- {
- "semi": true,
- "singleQuote": false,
- // ... other options
- }
+ "@kjanat/prettier-config"
If you need to keep some custom settings, extend instead:
// .prettierrc.mjs
import prettierConfig from "@kjanat/prettier-config";
export default {
...prettierConfig,
// Keep your custom settings
semi: false,
};
Most shareable configs follow the same pattern. Simply:
If you encounter module resolution issues:
package.json has "type": "module".cjs extension for your config filemoduleResolution is set to "bundler" or "node16" in tsconfig.jsonEnsure all peer dependencies are installed:
bun add -D prettier @prettier/plugin-xml prettier-plugin-packagejson prettier-plugin-tailwindcss
For TypeScript projects, ensure you have:
bun add -D @types/node typescript
# Clone the repository
git clone https://github.com/kjanat/prettier-config.git
cd prettier-config
# Install dependencies
bun install
# Build the package
bun run build
# Run tests
bun test
prettier-config/
├── src/ # Source files
│ └── index.ts # Main configuration
├── dist/ # Built output (git-ignored)
│ ├── index.js # Default ESM export
│ ├── index.mjs # Explicit ESM
│ ├── index.cjs # Explicit CommonJS
│ ├── index.d.ts # TypeScript definitions
│ ├── index.d.mts # ESM TypeScript definitions
│ └── index.d.cts # CommonJS TypeScript definitions
├── scripts/ # Build scripts
├── build.ts # Build configuration
├── package.json # Package manifest
└── tsconfig.json # TypeScript config
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)MIT © kjanat
Made with ❤️ using Bun
FAQs
Yet another Prettier config
The npm package @kjanat/prettier-config receives a total of 10 weekly downloads. As such, @kjanat/prettier-config popularity was classified as not popular.
We found that @kjanat/prettier-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Company News
Allow myself to introduce... myself.

Research
/Security News
A Twitch browser extension on Chrome and Firefox forwards users’ live OAuth session tokens through proxies controlled by a Russian bot service.

Security News
Anthropic found biased reasoning and recklessness drove Claude Mythos 5 to publish malware on PyPI and compromise a security vendor.