@youthfulhps/prettier-plugin-tailwindcss-normalizer 0.3.4
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/ast-transformer.d.ts +4 -0
- package/dist/ast-transformer.js +180 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +75 -0
- package/dist/mappings/effects/index.d.ts +2 -0
- package/dist/mappings/effects/index.js +7 -0
- package/dist/mappings/effects/shadows-opacity.d.ts +2 -0
- package/dist/mappings/effects/shadows-opacity.js +33 -0
- package/dist/mappings/filters/blur-effects.d.ts +2 -0
- package/dist/mappings/filters/blur-effects.js +141 -0
- package/dist/mappings/filters/index.d.ts +2 -0
- package/dist/mappings/filters/index.js +7 -0
- package/dist/mappings/index.d.ts +2 -0
- package/dist/mappings/index.js +23 -0
- package/dist/mappings/interactivity/index.d.ts +2 -0
- package/dist/mappings/interactivity/index.js +7 -0
- package/dist/mappings/interactivity/outline-ring-scroll.d.ts +2 -0
- package/dist/mappings/interactivity/outline-ring-scroll.js +68 -0
- package/dist/mappings/layout/borders-rounded.d.ts +2 -0
- package/dist/mappings/layout/borders-rounded.js +153 -0
- package/dist/mappings/layout/index.d.ts +2 -0
- package/dist/mappings/layout/index.js +9 -0
- package/dist/mappings/layout/positioning.d.ts +2 -0
- package/dist/mappings/layout/positioning.js +99 -0
- package/dist/mappings/sizing/height.d.ts +2 -0
- package/dist/mappings/sizing/height.js +173 -0
- package/dist/mappings/sizing/index.d.ts +2 -0
- package/dist/mappings/sizing/index.js +11 -0
- package/dist/mappings/sizing/size.d.ts +2 -0
- package/dist/mappings/sizing/size.js +62 -0
- package/dist/mappings/sizing/width.d.ts +2 -0
- package/dist/mappings/sizing/width.js +166 -0
- package/dist/mappings/spacing/gap-space.d.ts +2 -0
- package/dist/mappings/spacing/gap-space.js +70 -0
- package/dist/mappings/spacing/index.d.ts +2 -0
- package/dist/mappings/spacing/index.js +11 -0
- package/dist/mappings/spacing/margin.d.ts +2 -0
- package/dist/mappings/spacing/margin.js +587 -0
- package/dist/mappings/spacing/padding.d.ts +2 -0
- package/dist/mappings/spacing/padding.js +305 -0
- package/dist/mappings/transforms/index.d.ts +2 -0
- package/dist/mappings/transforms/index.js +7 -0
- package/dist/mappings/transforms/rotate-scale-translate.d.ts +2 -0
- package/dist/mappings/transforms/rotate-scale-translate.js +64 -0
- package/dist/mappings/transitions/duration-delay.d.ts +2 -0
- package/dist/mappings/transitions/duration-delay.js +36 -0
- package/dist/mappings/transitions/index.d.ts +2 -0
- package/dist/mappings/transitions/index.js +7 -0
- package/dist/mappings/typography/font-size.d.ts +2 -0
- package/dist/mappings/typography/font-size.js +40 -0
- package/dist/mappings/typography/index.d.ts +2 -0
- package/dist/mappings/typography/index.js +7 -0
- package/dist/normalizer.d.ts +3 -0
- package/dist/normalizer.js +123 -0
- package/dist/types/prettier-compat.d.ts +20 -0
- package/dist/types/prettier-compat.js +10 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.js +2 -0
- package/dist/utils/version-utils.d.ts +6 -0
- package/dist/utils/version-utils.js +89 -0
- package/package.json +69 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type ValueMapping = Record<string, string>;
|
|
2
|
+
export type TailwindMapping = {
|
|
3
|
+
p?: ValueMapping;
|
|
4
|
+
px?: ValueMapping;
|
|
5
|
+
py?: ValueMapping;
|
|
6
|
+
pt?: ValueMapping;
|
|
7
|
+
pr?: ValueMapping;
|
|
8
|
+
pb?: ValueMapping;
|
|
9
|
+
pl?: ValueMapping;
|
|
10
|
+
ps?: ValueMapping;
|
|
11
|
+
pe?: ValueMapping;
|
|
12
|
+
m?: ValueMapping;
|
|
13
|
+
mx?: ValueMapping;
|
|
14
|
+
my?: ValueMapping;
|
|
15
|
+
mt?: ValueMapping;
|
|
16
|
+
mr?: ValueMapping;
|
|
17
|
+
mb?: ValueMapping;
|
|
18
|
+
ml?: ValueMapping;
|
|
19
|
+
ms?: ValueMapping;
|
|
20
|
+
me?: ValueMapping;
|
|
21
|
+
w?: ValueMapping;
|
|
22
|
+
h?: ValueMapping;
|
|
23
|
+
size?: ValueMapping;
|
|
24
|
+
"min-w"?: ValueMapping;
|
|
25
|
+
"max-w"?: ValueMapping;
|
|
26
|
+
"min-h"?: ValueMapping;
|
|
27
|
+
"max-h"?: ValueMapping;
|
|
28
|
+
gap?: ValueMapping;
|
|
29
|
+
"gap-x"?: ValueMapping;
|
|
30
|
+
"gap-y"?: ValueMapping;
|
|
31
|
+
"space-x"?: ValueMapping;
|
|
32
|
+
"space-y"?: ValueMapping;
|
|
33
|
+
"space-x-reverse"?: ValueMapping;
|
|
34
|
+
"space-y-reverse"?: ValueMapping;
|
|
35
|
+
rounded?: ValueMapping;
|
|
36
|
+
"rounded-t"?: ValueMapping;
|
|
37
|
+
"rounded-r"?: ValueMapping;
|
|
38
|
+
"rounded-b"?: ValueMapping;
|
|
39
|
+
"rounded-l"?: ValueMapping;
|
|
40
|
+
"rounded-tl"?: ValueMapping;
|
|
41
|
+
"rounded-tr"?: ValueMapping;
|
|
42
|
+
"rounded-br"?: ValueMapping;
|
|
43
|
+
"rounded-bl"?: ValueMapping;
|
|
44
|
+
border?: ValueMapping;
|
|
45
|
+
"border-x"?: ValueMapping;
|
|
46
|
+
"border-y"?: ValueMapping;
|
|
47
|
+
"border-t"?: ValueMapping;
|
|
48
|
+
"border-r"?: ValueMapping;
|
|
49
|
+
"border-b"?: ValueMapping;
|
|
50
|
+
"border-l"?: ValueMapping;
|
|
51
|
+
text?: ValueMapping;
|
|
52
|
+
leading?: ValueMapping;
|
|
53
|
+
tracking?: ValueMapping;
|
|
54
|
+
shadow?: ValueMapping;
|
|
55
|
+
opacity?: ValueMapping;
|
|
56
|
+
ring?: ValueMapping;
|
|
57
|
+
"ring-offset"?: ValueMapping;
|
|
58
|
+
outline?: ValueMapping;
|
|
59
|
+
"outline-offset"?: ValueMapping;
|
|
60
|
+
duration?: ValueMapping;
|
|
61
|
+
"transition-duration"?: ValueMapping;
|
|
62
|
+
delay?: ValueMapping;
|
|
63
|
+
"focus:ring"?: ValueMapping;
|
|
64
|
+
"focus:ring-offset"?: ValueMapping;
|
|
65
|
+
rotate?: ValueMapping;
|
|
66
|
+
scale?: ValueMapping;
|
|
67
|
+
"translate-x"?: ValueMapping;
|
|
68
|
+
"translate-y"?: ValueMapping;
|
|
69
|
+
blur?: ValueMapping;
|
|
70
|
+
brightness?: ValueMapping;
|
|
71
|
+
contrast?: ValueMapping;
|
|
72
|
+
grayscale?: ValueMapping;
|
|
73
|
+
invert?: ValueMapping;
|
|
74
|
+
saturate?: ValueMapping;
|
|
75
|
+
sepia?: ValueMapping;
|
|
76
|
+
"hue-rotate"?: ValueMapping;
|
|
77
|
+
"backdrop-blur"?: ValueMapping;
|
|
78
|
+
"backdrop-brightness"?: ValueMapping;
|
|
79
|
+
"backdrop-contrast"?: ValueMapping;
|
|
80
|
+
"backdrop-grayscale"?: ValueMapping;
|
|
81
|
+
"backdrop-hue-rotate"?: ValueMapping;
|
|
82
|
+
"backdrop-invert"?: ValueMapping;
|
|
83
|
+
"backdrop-opacity"?: ValueMapping;
|
|
84
|
+
"backdrop-saturate"?: ValueMapping;
|
|
85
|
+
"backdrop-sepia"?: ValueMapping;
|
|
86
|
+
top?: ValueMapping;
|
|
87
|
+
right?: ValueMapping;
|
|
88
|
+
bottom?: ValueMapping;
|
|
89
|
+
left?: ValueMapping;
|
|
90
|
+
"scroll-m"?: ValueMapping;
|
|
91
|
+
"scroll-p"?: ValueMapping;
|
|
92
|
+
z?: ValueMapping;
|
|
93
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getPrettierMajorVersion(): number;
|
|
2
|
+
export declare function isPrettierV2(): boolean;
|
|
3
|
+
export declare function isPrettierV3Plus(): boolean;
|
|
4
|
+
export declare function loadParser(parserName: string): any;
|
|
5
|
+
export declare function getParserFromParsers(parsers: any, parserName: string): any;
|
|
6
|
+
export declare function safeLoadParser(parserName: string, specificParser?: string): any;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrettierMajorVersion = getPrettierMajorVersion;
|
|
4
|
+
exports.isPrettierV2 = isPrettierV2;
|
|
5
|
+
exports.isPrettierV3Plus = isPrettierV3Plus;
|
|
6
|
+
exports.loadParser = loadParser;
|
|
7
|
+
exports.getParserFromParsers = getParserFromParsers;
|
|
8
|
+
exports.safeLoadParser = safeLoadParser;
|
|
9
|
+
let prettierVersion = null;
|
|
10
|
+
function getPrettierMajorVersion() {
|
|
11
|
+
if (prettierVersion !== null) {
|
|
12
|
+
return prettierVersion;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const prettier = require("prettier");
|
|
16
|
+
if (prettier.version) {
|
|
17
|
+
const majorVersion = parseInt(prettier.version.split(".")[0]);
|
|
18
|
+
prettierVersion = majorVersion;
|
|
19
|
+
return majorVersion;
|
|
20
|
+
}
|
|
21
|
+
const prettierPackageJson = require("prettier/package.json");
|
|
22
|
+
if (prettierPackageJson.version) {
|
|
23
|
+
const majorVersion = parseInt(prettierPackageJson.version.split(".")[0]);
|
|
24
|
+
prettierVersion = majorVersion;
|
|
25
|
+
return majorVersion;
|
|
26
|
+
}
|
|
27
|
+
prettierVersion = 3;
|
|
28
|
+
return 3;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
prettierVersion = 3;
|
|
32
|
+
return 3;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function isPrettierV2() {
|
|
36
|
+
return getPrettierMajorVersion() === 2;
|
|
37
|
+
}
|
|
38
|
+
function isPrettierV3Plus() {
|
|
39
|
+
return getPrettierMajorVersion() >= 3;
|
|
40
|
+
}
|
|
41
|
+
function loadParser(parserName) {
|
|
42
|
+
const majorVersion = getPrettierMajorVersion();
|
|
43
|
+
const pathsToTry = [];
|
|
44
|
+
if (majorVersion >= 3) {
|
|
45
|
+
pathsToTry.push(`prettier/plugins/${parserName}`);
|
|
46
|
+
pathsToTry.push(`prettier/parser-${parserName}`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
pathsToTry.push(`prettier/parser-${parserName}`);
|
|
50
|
+
pathsToTry.push(`prettier/plugins/${parserName}`);
|
|
51
|
+
}
|
|
52
|
+
let lastError = null;
|
|
53
|
+
for (const path of pathsToTry) {
|
|
54
|
+
try {
|
|
55
|
+
return require(path);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
lastError = error;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`Failed to load parser: ${parserName}. ` +
|
|
63
|
+
`Prettier version: ${majorVersion}. ` +
|
|
64
|
+
`Tried paths: ${pathsToTry.join(", ")}. ` +
|
|
65
|
+
`Last error: ${lastError?.message}`);
|
|
66
|
+
}
|
|
67
|
+
function getParserFromParsers(parsers, parserName) {
|
|
68
|
+
if (!parsers) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
if (!parsers[parserName]) {
|
|
72
|
+
if (parserName === "angular" && Object.keys(parsers).length > 0) {
|
|
73
|
+
const firstParser = Object.keys(parsers)[0];
|
|
74
|
+
return parsers[firstParser];
|
|
75
|
+
}
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
return parsers[parserName];
|
|
79
|
+
}
|
|
80
|
+
function safeLoadParser(parserName, specificParser) {
|
|
81
|
+
try {
|
|
82
|
+
const parserModule = loadParser(parserName);
|
|
83
|
+
const targetParser = specificParser || parserName;
|
|
84
|
+
return getParserFromParsers(parserModule.parsers, targetParser);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@youthfulhps/prettier-plugin-tailwindcss-normalizer",
|
|
3
|
+
"version": "0.3.4",
|
|
4
|
+
"description": "A Prettier plugin that normalizes Tailwind CSS arbitrary values into standard utility classes.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -p tsconfig.build.json",
|
|
12
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"test:watch": "jest --watch",
|
|
15
|
+
"test:coverage": "jest --coverage",
|
|
16
|
+
"lint": "eslint src/**/*.ts",
|
|
17
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
18
|
+
"prepare": "npm run build",
|
|
19
|
+
"prepublishOnly": "npm run test && npm run lint && npm run build",
|
|
20
|
+
"release:patch": "npm version patch && git push origin main --tags",
|
|
21
|
+
"release:minor": "npm version minor && git push origin main --tags",
|
|
22
|
+
"release:major": "npm version major && git push origin main --tags",
|
|
23
|
+
"release:dry": "npm publish --dry-run",
|
|
24
|
+
"clean": "rm -rf dist coverage",
|
|
25
|
+
"test:local": "npm run build && npm pack && echo '✅ Local test package created! Use the .tgz file to test in other projects.'",
|
|
26
|
+
"test:install": "npm run test:local && npm install -g $(ls *.tgz | head -1) && echo '✅ Global installation completed!'",
|
|
27
|
+
"test:link": "npm run build && npm link && echo '✅ npm link completed! Run npm link prettier-plugin-tailwindcss-normalizer in other projects.'"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"prettier",
|
|
31
|
+
"plugin",
|
|
32
|
+
"tailwindcss",
|
|
33
|
+
"tailwind",
|
|
34
|
+
"normalize",
|
|
35
|
+
"formatter",
|
|
36
|
+
"css",
|
|
37
|
+
"utility-classes"
|
|
38
|
+
],
|
|
39
|
+
"author": "Your Name",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"prettier": ">=2.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/jest": "^29.5.8",
|
|
46
|
+
"@types/node": "^20.9.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
48
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
49
|
+
"eslint": "^8.57.1",
|
|
50
|
+
"jest": "^29.7.0",
|
|
51
|
+
"prettier": "^3.1.0",
|
|
52
|
+
"ts-jest": "^29.1.1",
|
|
53
|
+
"typescript": "^5.2.2"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@babel/generator": "^7.28.3",
|
|
57
|
+
"@babel/parser": "^7.28.3",
|
|
58
|
+
"@babel/traverse": "^7.28.3",
|
|
59
|
+
"@babel/types": "^7.28.2"
|
|
60
|
+
},
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://github.com/youthfulhps/prettier-plugin-tailwindcss-normalizer.git"
|
|
64
|
+
},
|
|
65
|
+
"bugs": {
|
|
66
|
+
"url": "https://github.com/youthfulhps/prettier-plugin-tailwindcss-normalizer/issues"
|
|
67
|
+
},
|
|
68
|
+
"homepage": "https://github.com/youthfulhps/prettier-plugin-tailwindcss-normalizer#readme"
|
|
69
|
+
}
|