@zayne-labs/prettier-config 0.11.5 → 0.11.6

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/dist/index.d.ts CHANGED
@@ -1,20 +1,8 @@
1
1
  import { AnyString } from "@zayne-labs/toolkit-type-helpers";
2
- import { Config } from "prettier";
2
+ import { Config, Plugin } from "prettier";
3
3
 
4
- //#region src/configs.d.ts
5
- declare const baseConfig: {
6
- experimentalOperatorPosition: "start";
7
- experimentalTernaries: true;
8
- jsxSingleQuote: false;
9
- printWidth: 107;
10
- singleQuote: false;
11
- tabWidth: 3;
12
- trailingComma: "es5";
13
- useTabs: true;
14
- } & {
15
- $inferUnion: "singleQuote" | "jsxSingleQuote" | "trailingComma" | "experimentalOperatorPosition" | "experimentalTernaries" | "printWidth" | "tabWidth" | "useTabs";
16
- };
17
- type ConfigWithTailwind = Omit<Config, "plugins"> & {
4
+ //#region src/types.d.ts
5
+ type OptionsTailwindCss = {
18
6
  /**
19
7
  * @docs [prettier-plugin-classnames#custom-attributes](https://github.com/ony3000/prettier-plugin-classnames#custom-attributes)
20
8
  */
@@ -27,7 +15,7 @@ type ConfigWithTailwind = Omit<Config, "plugins"> & {
27
15
  * @docs [prettier-plugin-classnames#ending-position](https://github.com/ony3000/prettier-plugin-classnames#ending-position)
28
16
  */
29
17
  endPosition?: "absolute" | "relative";
30
- plugins?: Array<"prettier-plugin-tailwindcss" | "prettier-plugin-classnames" | "prettier-plugin-merge" | AnyString>;
18
+ plugins?: Array<"prettier-plugin-tailwindcss" | "prettier-plugin-classnames" | "prettier-plugin-merge" | AnyString | Plugin | URL>;
31
19
  tailwindAttributes?: string[];
32
20
  tailwindConfig?: `./${string}`;
33
21
  tailwindFunctions?: string[];
@@ -35,63 +23,77 @@ type ConfigWithTailwind = Omit<Config, "plugins"> & {
35
23
  tailwindPreserveWhitespace?: boolean;
36
24
  tailwindStylesheet?: `./${string}`;
37
25
  };
38
- /**
39
- * @description Prettier configuration with Tailwind CSS support.
40
- *
41
- * @docs
42
- * - [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
43
- * - [prettier-plugin-classnames](https://github.com/ony3000/prettier-plugin-classnames)
44
- * - [prettier-plugin-merge](https://github.com/ony3000/prettier-plugin-merge)
45
- */
46
- declare const configWithTailwind: {
47
- customAttributes: ["classNames", "classes"];
48
- customFunctions: ["cnMerge", "cnJoin", "cn", "tv", "tw"];
49
- plugins: ["prettier-plugin-tailwindcss", "prettier-plugin-classnames", "prettier-plugin-merge"];
50
- tailwindAttributes: ["classNames", "classes"];
51
- tailwindFunctions: ["cnMerge", "cnJoin", "cn", "tv", "tw"];
52
- tailwindStylesheet: "./tailwind.css";
53
- experimentalOperatorPosition: "start";
54
- experimentalTernaries: true;
55
- jsxSingleQuote: false;
56
- printWidth: 107;
57
- singleQuote: false;
58
- tabWidth: 3;
59
- trailingComma: "es5";
60
- useTabs: true;
61
- $inferUnion: "singleQuote" | "jsxSingleQuote" | "trailingComma" | "experimentalOperatorPosition" | "experimentalTernaries" | "printWidth" | "tabWidth" | "useTabs";
62
- } & {
63
- $inferUnion: "singleQuote" | "jsxSingleQuote" | "trailingComma" | "plugins" | "experimentalOperatorPosition" | "experimentalTernaries" | "printWidth" | "tabWidth" | "useTabs" | "$inferUnion" | "customAttributes" | "customFunctions" | "tailwindAttributes" | "tailwindFunctions" | "tailwindStylesheet";
64
- };
65
- type ConfigWithAstro = Omit<Config, "plugins"> & {
26
+ type OptionsAstro = {
66
27
  astroAllowShorthand?: boolean;
67
28
  astroSkipFrontmatter?: boolean;
68
- plugins?: Array<"prettier-plugin-astro" | AnyString>;
69
- };
70
- /**
71
- * @description Prettier configuration with Astro support.
72
- *
73
- * @docs [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro#configuration)
74
- */
75
- declare const configWithAstro: {
76
- overrides: [{
29
+ overrides?: Array<{
77
30
  files: "*.astro";
78
31
  options: {
79
32
  parser: "astro";
80
33
  };
81
- }];
82
- plugins: ["prettier-plugin-astro"];
83
- experimentalOperatorPosition: "start";
84
- experimentalTernaries: true;
85
- jsxSingleQuote: false;
86
- printWidth: 107;
87
- singleQuote: false;
88
- tabWidth: 3;
89
- trailingComma: "es5";
90
- useTabs: true;
91
- $inferUnion: "singleQuote" | "jsxSingleQuote" | "trailingComma" | "experimentalOperatorPosition" | "experimentalTernaries" | "printWidth" | "tabWidth" | "useTabs";
92
- } & {
93
- $inferUnion: "singleQuote" | "jsxSingleQuote" | "trailingComma" | "plugins" | "experimentalOperatorPosition" | "experimentalTernaries" | "printWidth" | "tabWidth" | "useTabs" | "$inferUnion" | "overrides";
34
+ } | NonNullable<Config["overrides"]>[number]>;
35
+ plugins?: Array<"prettier-plugin-astro" | AnyString | Plugin | URL>;
36
+ };
37
+ type OptionsConfig = {
38
+ /**
39
+ * Astro configuration
40
+ * @default false
41
+ * @docs [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro#configuration)
42
+ */
43
+ astro?: boolean | OptionsAstro;
44
+ /**
45
+ * Base Prettier configuration with opinionated defaults.
46
+ * Includes settings for tabs, print width, quotes, trailing commas, and experimental features.
47
+ * @default true
48
+ */
49
+ base?: boolean | Config;
50
+ /**
51
+ * Tailwind CSS configuration
52
+ * @default false
53
+ * @docs
54
+ * - [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
55
+ * - [prettier-plugin-classnames](https://github.com/ony3000/prettier-plugin-classnames)
56
+ * - [prettier-plugin-merge](https://github.com/ony3000/prettier-plugin-merge)
57
+ */
58
+ tailwindcss?: boolean | OptionsTailwindCss;
94
59
  };
60
+ type ResolvedPrettierConfig = Config & OptionsAstro & OptionsTailwindCss;
61
+ type ExtractOptions<TUnion> = Extract<TUnion, object>;
62
+ //#endregion
63
+ //#region src/configs/astro.d.ts
64
+ declare const astro: (options: ExtractOptions<OptionsConfig["astro"]>) => typeof options;
65
+ //#endregion
66
+ //#region src/configs/base.d.ts
67
+ declare const base: (options: ExtractOptions<OptionsConfig["base"]>) => typeof options;
68
+ //#endregion
69
+ //#region src/configs/tailwindcss.d.ts
70
+ declare const tailwindcss: (options: ExtractOptions<OptionsConfig["tailwindcss"]>) => typeof options;
71
+ //#endregion
72
+ //#region src/factory.d.ts
73
+ /**
74
+ * @description Factory function for creating a customized Prettier configuration.
75
+ * Combines base, Astro, and Tailwind CSS configurations based on the provided options.
76
+ * Any Array values (like `plugins` and `overrides`) are merged, while other values are overwritten.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * // prettier.config.ts
81
+ * import { zayne } from "@zayne-labs/prettier-config";
82
+ *
83
+ * export default zayne(
84
+ * {
85
+ * base: true,
86
+ * tailwindcss: { tailwindStylesheet: "./src/styles.css" },
87
+ * astro: true,
88
+ * },
89
+ * // Extra config to merge (optional)
90
+ * {
91
+ * semi: false,
92
+ * }
93
+ * );
94
+ * ```
95
+ */
96
+ declare const zayne: (options?: OptionsConfig, ...extraConfigs: ResolvedPrettierConfig[]) => ResolvedPrettierConfig;
95
97
  //#endregion
96
- export { ConfigWithAstro, ConfigWithTailwind, baseConfig, configWithAstro, configWithTailwind };
98
+ export { ExtractOptions, OptionsAstro, OptionsConfig, OptionsTailwindCss, ResolvedPrettierConfig, astro, base, tailwindcss, zayne };
97
99
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,63 +1,137 @@
1
- import { defineEnum, defineEnumDeep } from "@zayne-labs/toolkit-type-helpers";
1
+ import { isArray, isObject } from "@zayne-labs/toolkit-type-helpers";
2
2
 
3
- //#region src/configs.ts
4
- const baseConfig = defineEnum({
5
- experimentalOperatorPosition: "start",
6
- experimentalTernaries: true,
7
- jsxSingleQuote: false,
8
- printWidth: 107,
9
- singleQuote: false,
10
- tabWidth: 3,
11
- trailingComma: "es5",
12
- useTabs: true
13
- });
3
+ //#region src/configs/astro.ts
4
+ const astro = (options) => {
5
+ return {
6
+ ...options,
7
+ overrides: [{
8
+ files: "*.astro",
9
+ options: { parser: "astro" }
10
+ }, ...options.overrides ?? []],
11
+ plugins: ["prettier-plugin-astro", ...options.plugins ?? []]
12
+ };
13
+ };
14
+
15
+ //#endregion
16
+ //#region src/configs/base.ts
17
+ const base = (options) => {
18
+ return {
19
+ experimentalOperatorPosition: "start",
20
+ experimentalTernaries: true,
21
+ jsxSingleQuote: false,
22
+ printWidth: 107,
23
+ singleQuote: false,
24
+ tabWidth: 3,
25
+ trailingComma: "es5",
26
+ useTabs: true,
27
+ ...options
28
+ };
29
+ };
30
+
31
+ //#endregion
32
+ //#region src/configs/tailwindcss.ts
33
+ const tailwindcss = (options) => {
34
+ return {
35
+ ...options,
36
+ customAttributes: [
37
+ "classNames",
38
+ "classes",
39
+ ...options.customAttributes ?? []
40
+ ],
41
+ customFunctions: [
42
+ "cnMerge",
43
+ "cnJoin",
44
+ "cn",
45
+ "tv",
46
+ "tw",
47
+ ...options.customFunctions ?? []
48
+ ],
49
+ plugins: [
50
+ "prettier-plugin-tailwindcss",
51
+ "prettier-plugin-classnames",
52
+ "prettier-plugin-merge",
53
+ ...options.plugins ?? []
54
+ ],
55
+ tailwindAttributes: [
56
+ "classNames",
57
+ "classes",
58
+ ...options.tailwindAttributes ?? []
59
+ ],
60
+ tailwindFunctions: [
61
+ "cnMerge",
62
+ "cnJoin",
63
+ "cn",
64
+ "tv",
65
+ "tw",
66
+ ...options.tailwindFunctions ?? []
67
+ ],
68
+ tailwindStylesheet: options.tailwindStylesheet ?? "./tailwind.css"
69
+ };
70
+ };
71
+
72
+ //#endregion
73
+ //#region src/utils.ts
14
74
  /**
15
- * @description Prettier configuration with Tailwind CSS support.
16
- *
17
- * @docs
18
- * - [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
19
- * - [prettier-plugin-classnames](https://github.com/ony3000/prettier-plugin-classnames)
20
- * - [prettier-plugin-merge](https://github.com/ony3000/prettier-plugin-merge)
75
+ * @description Resolves a boolean or object option to an object.
76
+ * If the option is an object, it returns it as-is. Otherwise, returns an empty object.
77
+ */
78
+ const resolveOptions = (option) => {
79
+ return isObject(option) ? option : {};
80
+ };
81
+ /**
82
+ * @description Merges two Prettier configurations.
83
+ * Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.
21
84
  */
22
- const configWithTailwind = defineEnumDeep({
23
- ...baseConfig,
24
- customAttributes: ["classNames", "classes"],
25
- customFunctions: [
26
- "cnMerge",
27
- "cnJoin",
28
- "cn",
29
- "tv",
30
- "tw"
31
- ],
32
- plugins: [
33
- "prettier-plugin-tailwindcss",
34
- "prettier-plugin-classnames",
35
- "prettier-plugin-merge"
36
- ],
37
- tailwindAttributes: ["classNames", "classes"],
38
- tailwindFunctions: [
39
- "cnMerge",
40
- "cnJoin",
41
- "cn",
42
- "tv",
43
- "tw"
44
- ],
45
- tailwindStylesheet: "./tailwind.css"
46
- });
85
+ const mergeTwoConfigs = (formerConfig, latterConfig) => {
86
+ const configAccumulator = { ...formerConfig };
87
+ for (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {
88
+ const accumulatedConfigValue = configAccumulator[latterConfigKey];
89
+ configAccumulator[latterConfigKey] = isArray(latterConfigValue) && isArray(accumulatedConfigValue) ? [...accumulatedConfigValue, ...latterConfigValue] : latterConfigValue;
90
+ }
91
+ return configAccumulator;
92
+ };
93
+
94
+ //#endregion
95
+ //#region src/factory.ts
47
96
  /**
48
- * @description Prettier configuration with Astro support.
97
+ * @description Factory function for creating a customized Prettier configuration.
98
+ * Combines base, Astro, and Tailwind CSS configurations based on the provided options.
99
+ * Any Array values (like `plugins` and `overrides`) are merged, while other values are overwritten.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * // prettier.config.ts
104
+ * import { zayne } from "@zayne-labs/prettier-config";
49
105
  *
50
- * @docs [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro#configuration)
106
+ * export default zayne(
107
+ * {
108
+ * base: true,
109
+ * tailwindcss: { tailwindStylesheet: "./src/styles.css" },
110
+ * astro: true,
111
+ * },
112
+ * // Extra config to merge (optional)
113
+ * {
114
+ * semi: false,
115
+ * }
116
+ * );
117
+ * ```
51
118
  */
52
- const configWithAstro = defineEnumDeep({
53
- ...baseConfig,
54
- overrides: [{
55
- files: "*.astro",
56
- options: { parser: "astro" }
57
- }],
58
- plugins: ["prettier-plugin-astro"]
59
- });
119
+ const zayne = (options = {}, ...extraConfigs) => {
120
+ const { astro: enabledAstro = false, base: enabledBase = true, tailwindcss: enabledTailwindcss = false } = options;
121
+ const configArray = [
122
+ enabledBase ? base(resolveOptions(enabledBase)) : void 0,
123
+ enabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : void 0,
124
+ enabledAstro ? astro(resolveOptions(enabledAstro)) : void 0,
125
+ ...extraConfigs
126
+ ];
127
+ let resolvedConfig = {};
128
+ for (const config of configArray) {
129
+ if (!config) continue;
130
+ resolvedConfig = mergeTwoConfigs(resolvedConfig, config);
131
+ }
132
+ return resolvedConfig;
133
+ };
60
134
 
61
135
  //#endregion
62
- export { baseConfig, configWithAstro, configWithTailwind };
136
+ export { astro, base, tailwindcss, zayne };
63
137
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/configs.ts"],"sourcesContent":["import { type AnyString, defineEnum, defineEnumDeep } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { Config } from \"prettier\";\n\nexport const baseConfig = defineEnum({\n\texperimentalOperatorPosition: \"start\",\n\texperimentalTernaries: true,\n\tjsxSingleQuote: false,\n\tprintWidth: 107,\n\tsingleQuote: false,\n\ttabWidth: 3,\n\ttrailingComma: \"es5\",\n\tuseTabs: true,\n}) satisfies Config;\n\nexport type ConfigWithTailwind = Omit<Config, \"plugins\"> & {\n\t/**\n\t * @docs [prettier-plugin-classnames#custom-attributes](https://github.com/ony3000/prettier-plugin-classnames#custom-attributes)\n\t */\n\tcustomAttributes?: string[];\n\t/**\n\t * @docs [prettier-plugin-classnames#custom-functions](https://github.com/ony3000/prettier-plugin-classnames#custom-functions)\n\t */\n\tcustomFunctions?: string[];\n\t/**\n\t * @docs [prettier-plugin-classnames#ending-position](https://github.com/ony3000/prettier-plugin-classnames#ending-position)\n\t */\n\tendPosition?: \"absolute\" | \"relative\";\n\tplugins?: Array<\n\t\t// eslint-disable-next-line perfectionist/sort-union-types -- prettier-plugin-tailwindcss should come before prettier-plugin-classnames\n\t\t\"prettier-plugin-tailwindcss\" | \"prettier-plugin-classnames\" | \"prettier-plugin-merge\" | AnyString\n\t>;\n\ttailwindAttributes?: string[];\n\ttailwindConfig?: `./${string}`;\n\ttailwindFunctions?: string[];\n\ttailwindPreserveDuplicates?: boolean;\n\ttailwindPreserveWhitespace?: boolean;\n\ttailwindStylesheet?: `./${string}`;\n};\n\n/**\n * @description Prettier configuration with Tailwind CSS support.\n *\n * @docs\n * - [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)\n * - [prettier-plugin-classnames](https://github.com/ony3000/prettier-plugin-classnames)\n * - [prettier-plugin-merge](https://github.com/ony3000/prettier-plugin-merge)\n */\nexport const configWithTailwind = defineEnumDeep({\n\t...baseConfig,\n\n\tcustomAttributes: [\"classNames\", \"classes\"],\n\tcustomFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\"],\n\tplugins: [\"prettier-plugin-tailwindcss\", \"prettier-plugin-classnames\", \"prettier-plugin-merge\"],\n\ttailwindAttributes: [\"classNames\", \"classes\"],\n\ttailwindFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\"],\n\ttailwindStylesheet: \"./tailwind.css\",\n}) satisfies ConfigWithTailwind;\n\nexport type ConfigWithAstro = Omit<Config, \"plugins\"> & {\n\tastroAllowShorthand?: boolean;\n\tastroSkipFrontmatter?: boolean;\n\tplugins?: Array<\"prettier-plugin-astro\" | AnyString>;\n};\n\n/**\n * @description Prettier configuration with Astro support.\n *\n * @docs [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro#configuration)\n */\n\nexport const configWithAstro = defineEnumDeep({\n\t...baseConfig,\n\n\toverrides: [\n\t\t{\n\t\t\tfiles: \"*.astro\",\n\t\t\toptions: {\n\t\t\t\tparser: \"astro\",\n\t\t\t},\n\t\t},\n\t],\n\tplugins: [\"prettier-plugin-astro\"],\n}) satisfies ConfigWithAstro;\n"],"mappings":";;;AAGA,MAAa,aAAa,WAAW;CACpC,8BAA8B;CAC9B,uBAAuB;CACvB,gBAAgB;CAChB,YAAY;CACZ,aAAa;CACb,UAAU;CACV,eAAe;CACf,SAAS;CACT,CAAC;;;;;;;;;AAmCF,MAAa,qBAAqB,eAAe;CAChD,GAAG;CAEH,kBAAkB,CAAC,cAAc,UAAU;CAC3C,iBAAiB;EAAC;EAAW;EAAU;EAAM;EAAM;EAAK;CACxD,SAAS;EAAC;EAA+B;EAA8B;EAAwB;CAC/F,oBAAoB,CAAC,cAAc,UAAU;CAC7C,mBAAmB;EAAC;EAAW;EAAU;EAAM;EAAM;EAAK;CAC1D,oBAAoB;CACpB,CAAC;;;;;;AAcF,MAAa,kBAAkB,eAAe;CAC7C,GAAG;CAEH,WAAW,CACV;EACC,OAAO;EACP,SAAS,EACR,QAAQ,SACR;EACD,CACD;CACD,SAAS,CAAC,wBAAwB;CAClC,CAAC"}
1
+ {"version":3,"file":"index.js","names":["configAccumulator: ResolvedPrettierConfig","configArray: Array<ResolvedPrettierConfig | undefined>","resolvedConfig: ResolvedPrettierConfig"],"sources":["../src/configs/astro.ts","../src/configs/base.ts","../src/configs/tailwindcss.ts","../src/utils.ts","../src/factory.ts"],"sourcesContent":["import type { ExtractOptions, OptionsConfig } from \"@/types\";\n\nexport const astro = (options: ExtractOptions<OptionsConfig[\"astro\"]>): typeof options => {\n\treturn {\n\t\t...options,\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: \"*.astro\",\n\t\t\t\toptions: { parser: \"astro\" },\n\t\t\t},\n\t\t\t...(options.overrides ?? []),\n\t\t],\n\t\tplugins: [\"prettier-plugin-astro\", ...(options.plugins ?? [])],\n\t};\n};\n","import type { ExtractOptions, OptionsConfig } from \"@/types\";\n\nexport const base = (options: ExtractOptions<OptionsConfig[\"base\"]>): typeof options => {\n\treturn {\n\t\texperimentalOperatorPosition: \"start\",\n\t\texperimentalTernaries: true,\n\t\tjsxSingleQuote: false,\n\t\tprintWidth: 107,\n\t\tsingleQuote: false,\n\t\ttabWidth: 3,\n\t\ttrailingComma: \"es5\",\n\t\tuseTabs: true,\n\t\t...options,\n\t};\n};\n","import type { ExtractOptions, OptionsConfig } from \"@/types\";\n\nexport const tailwindcss = (options: ExtractOptions<OptionsConfig[\"tailwindcss\"]>): typeof options => {\n\treturn {\n\t\t...options,\n\t\tcustomAttributes: [\"classNames\", \"classes\", ...(options.customAttributes ?? [])],\n\t\tcustomFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\", ...(options.customFunctions ?? [])],\n\t\tplugins: [\n\t\t\t\"prettier-plugin-tailwindcss\",\n\t\t\t\"prettier-plugin-classnames\",\n\t\t\t\"prettier-plugin-merge\",\n\t\t\t...(options.plugins ?? []),\n\t\t],\n\t\ttailwindAttributes: [\"classNames\", \"classes\", ...(options.tailwindAttributes ?? [])],\n\t\ttailwindFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\", ...(options.tailwindFunctions ?? [])],\n\t\ttailwindStylesheet: options.tailwindStylesheet ?? \"./tailwind.css\",\n\t};\n};\n","import { isArray, isObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { ResolvedPrettierConfig } from \"./types\";\n\n/**\n * @description Resolves a boolean or object option to an object.\n * If the option is an object, it returns it as-is. Otherwise, returns an empty object.\n */\nexport const resolveOptions = <TObject>(option: boolean | TObject | undefined) => {\n\treturn isObject(option) ? option : ({} as TObject);\n};\n\n/**\n * @description Merges two Prettier configurations.\n * Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.\n */\nexport const mergeTwoConfigs = (\n\tformerConfig: ResolvedPrettierConfig,\n\tlatterConfig: ResolvedPrettierConfig\n): ResolvedPrettierConfig => {\n\tconst configAccumulator: ResolvedPrettierConfig = {\n\t\t...formerConfig,\n\t};\n\n\tfor (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {\n\t\tconst accumulatedConfigValue = configAccumulator[latterConfigKey];\n\n\t\tconfigAccumulator[latterConfigKey] =\n\t\t\tisArray(latterConfigValue) && isArray(accumulatedConfigValue) ?\n\t\t\t\t[...accumulatedConfigValue, ...latterConfigValue]\n\t\t\t:\tlatterConfigValue;\n\t}\n\n\treturn configAccumulator;\n};\n","import { astro, base, tailwindcss } from \"./configs\";\nimport type { OptionsConfig, ResolvedPrettierConfig } from \"./types\";\nimport { mergeTwoConfigs, resolveOptions } from \"./utils\";\n\n/**\n * @description Factory function for creating a customized Prettier configuration.\n * Combines base, Astro, and Tailwind CSS configurations based on the provided options.\n * Any Array values (like `plugins` and `overrides`) are merged, while other values are overwritten.\n *\n * @example\n * ```ts\n * // prettier.config.ts\n * import { zayne } from \"@zayne-labs/prettier-config\";\n *\n * export default zayne(\n * {\n * base: true,\n * tailwindcss: { tailwindStylesheet: \"./src/styles.css\" },\n * astro: true,\n * },\n * // Extra config to merge (optional)\n * {\n * semi: false,\n * }\n * );\n * ```\n */\nexport const zayne = (options: OptionsConfig = {}, ...extraConfigs: ResolvedPrettierConfig[]) => {\n\tconst {\n\t\tastro: enabledAstro = false,\n\t\tbase: enabledBase = true,\n\t\ttailwindcss: enabledTailwindcss = false,\n\t} = options;\n\n\tconst configArray: Array<ResolvedPrettierConfig | undefined> = [\n\t\tenabledBase ? base(resolveOptions(enabledBase)) : undefined,\n\t\tenabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : undefined,\n\t\tenabledAstro ? astro(resolveOptions(enabledAstro)) : undefined,\n\t\t...extraConfigs,\n\t];\n\n\tlet resolvedConfig: ResolvedPrettierConfig = {};\n\n\tfor (const config of configArray) {\n\t\tif (!config) continue;\n\n\t\tresolvedConfig = mergeTwoConfigs(resolvedConfig, config);\n\t}\n\n\treturn resolvedConfig;\n};\n"],"mappings":";;;AAEA,MAAa,SAAS,YAAoE;AACzF,QAAO;EACN,GAAG;EACH,WAAW,CACV;GACC,OAAO;GACP,SAAS,EAAE,QAAQ,SAAS;GAC5B,EACD,GAAI,QAAQ,aAAa,EAAE,CAC3B;EACD,SAAS,CAAC,yBAAyB,GAAI,QAAQ,WAAW,EAAE,CAAE;EAC9D;;;;;ACXF,MAAa,QAAQ,YAAmE;AACvF,QAAO;EACN,8BAA8B;EAC9B,uBAAuB;EACvB,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,UAAU;EACV,eAAe;EACf,SAAS;EACT,GAAG;EACH;;;;;ACXF,MAAa,eAAe,YAA0E;AACrG,QAAO;EACN,GAAG;EACH,kBAAkB;GAAC;GAAc;GAAW,GAAI,QAAQ,oBAAoB,EAAE;GAAE;EAChF,iBAAiB;GAAC;GAAW;GAAU;GAAM;GAAM;GAAM,GAAI,QAAQ,mBAAmB,EAAE;GAAE;EAC5F,SAAS;GACR;GACA;GACA;GACA,GAAI,QAAQ,WAAW,EAAE;GACzB;EACD,oBAAoB;GAAC;GAAc;GAAW,GAAI,QAAQ,sBAAsB,EAAE;GAAE;EACpF,mBAAmB;GAAC;GAAW;GAAU;GAAM;GAAM;GAAM,GAAI,QAAQ,qBAAqB,EAAE;GAAE;EAChG,oBAAoB,QAAQ,sBAAsB;EAClD;;;;;;;;;ACTF,MAAa,kBAA2B,WAA0C;AACjF,QAAO,SAAS,OAAO,GAAG,SAAU,EAAE;;;;;;AAOvC,MAAa,mBACZ,cACA,iBAC4B;CAC5B,MAAMA,oBAA4C,EACjD,GAAG,cACH;AAED,MAAK,MAAM,CAAC,iBAAiB,sBAAsB,OAAO,QAAQ,aAAa,EAAE;EAChF,MAAM,yBAAyB,kBAAkB;AAEjD,oBAAkB,mBACjB,QAAQ,kBAAkB,IAAI,QAAQ,uBAAuB,GAC5D,CAAC,GAAG,wBAAwB,GAAG,kBAAkB,GAChD;;AAGJ,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACLR,MAAa,SAAS,UAAyB,EAAE,EAAE,GAAG,iBAA2C;CAChG,MAAM,EACL,OAAO,eAAe,OACtB,MAAM,cAAc,MACpB,aAAa,qBAAqB,UAC/B;CAEJ,MAAMC,cAAyD;EAC9D,cAAc,KAAK,eAAe,YAAY,CAAC,GAAG;EAClD,qBAAqB,YAAY,eAAe,mBAAmB,CAAC,GAAG;EACvE,eAAe,MAAM,eAAe,aAAa,CAAC,GAAG;EACrD,GAAG;EACH;CAED,IAAIC,iBAAyC,EAAE;AAE/C,MAAK,MAAM,UAAU,aAAa;AACjC,MAAI,CAAC,OAAQ;AAEb,mBAAiB,gBAAgB,gBAAgB,OAAO;;AAGzD,QAAO"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zayne-labs/prettier-config",
3
3
  "type": "module",
4
- "version": "0.11.5",
4
+ "version": "0.11.6",
5
5
  "description": "Zayne Labs' Prettier config",
6
6
  "author": "Ryan Zayne",
7
7
  "license": "MIT",
@@ -29,18 +29,18 @@
29
29
  "node": ">=18.x"
30
30
  },
31
31
  "dependencies": {
32
- "@zayne-labs/toolkit-type-helpers": "^0.12.12"
32
+ "@zayne-labs/toolkit-type-helpers": "^0.12.16"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@arethetypeswrong/cli": "^0.18.2",
36
- "@changesets/cli": "^2.29.7",
36
+ "@changesets/cli": "^2.29.8",
37
37
  "@total-typescript/ts-reset": "^0.6.1",
38
38
  "concurrently": "^9.2.1",
39
39
  "cross-env": "^10.1.0",
40
- "publint": "^0.3.15",
41
- "tsdown": "^0.16.0",
40
+ "publint": "^0.3.16",
41
+ "tsdown": "^0.18.2",
42
42
  "typescript": "5.9.3",
43
- "@zayne-labs/tsconfig": "0.11.5"
43
+ "@zayne-labs/tsconfig": "0.11.6"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",