@jmlweb/prettier-config-tailwind 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -0
- package/dist/index.cjs +41 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @jmlweb/prettier-config-tailwind
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@jmlweb/prettier-config-tailwind)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
|
|
7
|
+
> Prettier configuration with Tailwind CSS class sorting. Extends `@jmlweb/prettier-config-base` with automatic Tailwind class organization.
|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- 🎨 **Tailwind Class Sorting**: Automatically sorts Tailwind CSS classes in the recommended order
|
|
12
|
+
- 🔧 **Base Config Included**: Inherits all settings from `@jmlweb/prettier-config-base`
|
|
13
|
+
- 🚀 **Zero Configuration**: Works out of the box with Tailwind projects
|
|
14
|
+
- 📦 **Plugin Integration**: Uses `prettier-plugin-tailwindcss` for optimal class ordering
|
|
15
|
+
|
|
16
|
+
## 📦 Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save-dev @jmlweb/prettier-config-tailwind prettier prettier-plugin-tailwindcss
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Note**: The `prettier-plugin-tailwindcss` plugin must be installed as a dev dependency.
|
|
23
|
+
|
|
24
|
+
## 🚀 Quick Start
|
|
25
|
+
|
|
26
|
+
### Option 1: Using `package.json` (Recommended)
|
|
27
|
+
|
|
28
|
+
Add to your `package.json`:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"prettier": "@jmlweb/prettier-config-tailwind"
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Option 2: Using `.prettierrc.js`
|
|
37
|
+
|
|
38
|
+
Create a `.prettierrc.js` file in your project root:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
module.exports = require('@jmlweb/prettier-config-tailwind');
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 💡 Examples
|
|
45
|
+
|
|
46
|
+
### Before Formatting
|
|
47
|
+
|
|
48
|
+
```jsx
|
|
49
|
+
<button className="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
50
|
+
Click me
|
|
51
|
+
</button>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### After Formatting (Classes Automatically Sorted)
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
<button className="rounded-lg bg-blue-500 px-4 py-2 text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
58
|
+
Click me
|
|
59
|
+
</button>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The plugin automatically sorts classes following Tailwind's recommended order:
|
|
63
|
+
|
|
64
|
+
1. Layout (display, position, etc.)
|
|
65
|
+
2. Flexbox & Grid
|
|
66
|
+
3. Spacing (padding, margin)
|
|
67
|
+
4. Sizing (width, height)
|
|
68
|
+
5. Typography
|
|
69
|
+
6. Backgrounds
|
|
70
|
+
7. Borders
|
|
71
|
+
8. Effects (shadows, etc.)
|
|
72
|
+
9. Transforms & Transitions
|
|
73
|
+
10. Interactivity (hover, focus, etc.)
|
|
74
|
+
|
|
75
|
+
## 📋 Configuration
|
|
76
|
+
|
|
77
|
+
This package extends `@jmlweb/prettier-config-base` and adds:
|
|
78
|
+
|
|
79
|
+
- ✅ All base configuration options:
|
|
80
|
+
- Semicolons, single quotes, 2-space indentation
|
|
81
|
+
- Trailing commas, LF line endings
|
|
82
|
+
- And all other base settings
|
|
83
|
+
- ✅ `prettier-plugin-tailwindcss` - Automatically sorts Tailwind CSS classes
|
|
84
|
+
|
|
85
|
+
## 🔧 Usage with Scripts
|
|
86
|
+
|
|
87
|
+
Add formatting scripts to your `package.json`:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"scripts": {
|
|
92
|
+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
|
|
93
|
+
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md}\""
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 🎯 When to Use
|
|
99
|
+
|
|
100
|
+
Use this package when:
|
|
101
|
+
|
|
102
|
+
- ✅ You're using Tailwind CSS in your project
|
|
103
|
+
- ✅ You want consistent class ordering across your codebase
|
|
104
|
+
- ✅ You want to follow Tailwind's recommended class order
|
|
105
|
+
- ✅ You want automatic class sorting on save/format
|
|
106
|
+
|
|
107
|
+
For projects without Tailwind, use [`@jmlweb/prettier-config-base`](../prettier-config-base) instead.
|
|
108
|
+
|
|
109
|
+
## 🔗 Related Packages
|
|
110
|
+
|
|
111
|
+
- [`@jmlweb/prettier-config-base`](../prettier-config-base) - Base Prettier configuration (extended by this package)
|
|
112
|
+
- [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint config for TypeScript projects
|
|
113
|
+
|
|
114
|
+
## ⚠️ Important Notes
|
|
115
|
+
|
|
116
|
+
1. **Plugin Installation**: Make sure `prettier-plugin-tailwindcss` is installed. It's a peer dependency.
|
|
117
|
+
2. **Class Ordering**: The plugin uses Tailwind's recommended class order. This may differ from your current ordering.
|
|
118
|
+
3. **Performance**: The plugin must be loaded last in Prettier's plugin chain (it handles this automatically).
|
|
119
|
+
|
|
120
|
+
## 📝 Requirements
|
|
121
|
+
|
|
122
|
+
- **Node.js** >= 18.0.0
|
|
123
|
+
- **Prettier** >= 3.0.0
|
|
124
|
+
- **prettier-plugin-tailwindcss** (peer dependency)
|
|
125
|
+
|
|
126
|
+
## 📄 License
|
|
127
|
+
|
|
128
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => index_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_prettier_config_base = __toESM(require("@jmlweb/prettier-config-base"), 1);
|
|
37
|
+
var config = {
|
|
38
|
+
...import_prettier_config_base.default,
|
|
39
|
+
plugins: ["prettier-plugin-tailwindcss"]
|
|
40
|
+
};
|
|
41
|
+
var index_default = config;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jmlweb/prettier-config-tailwind",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Prettier configuration for jmlweb projects with Tailwind CSS support",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": {
|
|
12
|
+
"types": "./dist/index.d.cts",
|
|
13
|
+
"default": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"prepublishOnly": "pnpm build"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"prettier",
|
|
32
|
+
"prettier-config",
|
|
33
|
+
"tailwind",
|
|
34
|
+
"tailwindcss",
|
|
35
|
+
"code-formatter"
|
|
36
|
+
],
|
|
37
|
+
"author": "jmlweb",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/jmlweb/tooling.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/jmlweb/tooling/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/jmlweb/tooling/tree/main/packages/prettier-config-tailwind#readme",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"prettier": "^3.0.0"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@jmlweb/prettier-config-base": "workspace:*",
|
|
58
|
+
"prettier-plugin-tailwindcss": "^0.6.9"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@jmlweb/tsconfig-internal": "workspace:*",
|
|
62
|
+
"prettier": "^3.3.3",
|
|
63
|
+
"tsup": "^8.5.1",
|
|
64
|
+
"typescript": "^5.9.3"
|
|
65
|
+
}
|
|
66
|
+
}
|