@zayne-labs/prettier-config 0.11.7 → 0.11.9

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 CHANGED
@@ -1,6 +1,14 @@
1
1
  # @zayne-labs/prettier-config
2
2
 
3
- Shared Prettier configuration for Zayne Labs projects.
3
+ Shared Prettier configuration for Zayne Labs projects, featuring a modular factory system with automatic plugin detection and refined sorting logic.
4
+
5
+ ## Features
6
+
7
+ - **Modular Factory**: Easily toggle features like Tailwind, Astro, and Import Sorting.
8
+ - **Smart Import Sorting**: Distance-based sorting (URLs → Protocols → Packages → Aliases → Paths).
9
+ - **Tailwind CSS v4 Ready**: Support for `tailwindStylesheet` and advanced class sorting.
10
+ - **Auto-Installation**: Prompts to install missing plugins when needed.
11
+ - **Deduplicated Configs**: Merges arrays (plugins, overrides) intelligently without duplicates.
4
12
 
5
13
  ## Installation
6
14
 
@@ -10,91 +18,84 @@ pnpm add -D @zayne-labs/prettier-config
10
18
 
11
19
  ## Usage
12
20
 
13
- The package exports three configurations:
14
-
15
- ### Base Config
16
-
17
- Basic Prettier configuration without any plugins.
18
-
19
- ```js
20
- import { baseConfig } from "@zayne-labs/prettier-config";
21
+ The package exports a factory function `zayne` that combines disparate config segments.
21
22
 
22
- export default baseConfig;
23
- ```
23
+ ```ts
24
+ // prettier.config.js
25
+ import { zayne } from "@zayne-labs/prettier-config";
24
26
 
25
- **Configuration in `baseConfig`:**
26
-
27
- ```js
28
- export default {
29
- experimentalOperatorPosition: "start",
30
- experimentalTernaries: true,
31
- jsxSingleQuote: false,
32
- printWidth: 107,
33
- singleQuote: false,
34
- tabWidth: 3,
35
- trailingComma: "es5",
36
- useTabs: true,
37
- };
27
+ export default zayne({
28
+ base: true, // Enabled by default
29
+ sortImports: true, // Enabled by default
30
+ tailwindcss: true,
31
+ astro: true,
32
+ // ...more to come
33
+ });
38
34
  ```
39
35
 
40
- ### Tailwind Config
41
-
42
- Extended base configuration with Tailwind CSS support. Includes plugins for class sorting, merging, and formatting.
36
+ ### Options
43
37
 
44
- ```js
45
- import { configWithTailwind } from "@zayne-labs/prettier-config";
38
+ The `zayne` factory accepts an options object as the first argument:
46
39
 
47
- export default configWithTailwind;
48
- ```
40
+ | Option | Type | Default | Description |
41
+ | ------------- | ------------------------------- | ------- | ---------------------------------------------- |
42
+ | `base` | `boolean \| Config` | `true` | Opinionated base defaults. |
43
+ | `sortImports` | `boolean \| OptionsSortImports` | `true` | Enables `@ianvs/prettier-plugin-sort-imports`. |
44
+ | `tailwindcss` | `boolean \| OptionsTailwindCss` | `false` | Enables Tailwind and ClassNames plugins. |
45
+ | `astro` | `boolean \| OptionsAstro` | `false` | Enables `prettier-plugin-astro`. |
49
46
 
50
- **Plugins included:**
47
+ ### Default Import Sorting Rules
51
48
 
52
- - `prettier-plugin-tailwindcss` - Sorts Tailwind classes
53
- - `prettier-plugin-classnames` - Formats className strings
54
- - `prettier-plugin-merge` - Merges plugin functionality
49
+ When `sortImports` is enabled (which it is by default), imports are organized by "distance" from the current file:
55
50
 
56
- **Default settings:**
51
+ 1. **User patterns**: Any custom patterns you pass via `importOrder` are prioritized at the top.
52
+ 2. **URLs**: Remote modules (e.g., `https://esm.sh/...`).
53
+ 3. **Protocols**: Built-ins and protocol imports (`node:`, `bun:`, `jsr:`, `npm:`).
54
+ 4. **Packages**: Third-party modules (e.g., `react`, `lodash`).
55
+ 5. **Aliases**: Local aliases like `@/`, `#`, `~`, `$`, `%`.
56
+ 6. **Paths**: Relative and absolute file paths (excluding CSS).
57
+ 7. **CSS**: Style files are always pushed to the absolute bottom.
57
58
 
58
- - Custom attributes: `classNames`, `classes`
59
- - Custom functions: `cnMerge`, `cnJoin`, `cn`, `tv`, `tw`
60
- - Tailwind stylesheet: `./tailwind.css`
59
+ ### Tailwind & ClassNames Support
61
60
 
62
- **Note:** You'll need to install the plugins separately:
61
+ The Tailwind integration combines three plugins:
63
62
 
64
- ```bash
65
- pnpm add -D prettier-plugin-tailwindcss prettier-plugin-classnames prettier-plugin-merge
66
- ```
63
+ - `prettier-plugin-tailwindcss`: Sorts classes.
64
+ - `prettier-plugin-classnames`: Multi-line formatting & attribute support.
65
+ - `prettier-plugin-merge`: Ensures plugins work together.
67
66
 
68
- ### Astro Config
67
+ **Configurable Options:**
69
68
 
70
- Extended base configuration with Astro support.
71
-
72
- ```js
73
- import { configWithAstro } from "@zayne-labs/prettier-config";
74
-
75
- export default configWithAstro;
76
- ```
77
-
78
- **Note:** You'll need to install the plugin separately:
79
-
80
- ```bash
81
- pnpm add -D prettier-plugin-astro
82
- ```
69
+ - `customAttributes`: Additional attributes to sort classes in (e.g., `classNames`, `classes`).
70
+ - `customFunctions`: Functions to sort classes in (e.g., `cn`, `tv`, `tw`).
71
+ - `tailwindStylesheet`: Path to your CSS entry point (defaults to `./tailwind.css` for v4).
72
+ - `endPosition`: Criterion for ending class names (`absolute` or `relative`).
73
+ - `syntaxTransformation`: Auto-transform non-expression classes to expression syntax on wrap.
83
74
 
84
75
  ## Extending Configurations
85
76
 
86
- You can extend any configuration with your own options:
77
+ The factory accepts any number of extra configuration objects as subsequent arguments:
78
+
79
+ ```ts
80
+ import { zayne } from "@zayne-labs/prettier-config";
81
+
82
+ export default zayne(
83
+ {
84
+ tailwindcss: true,
85
+ },
86
+ // Extra config objects to merge
87
+ {
88
+ printWidth: 120,
89
+ semi: true,
90
+ }
91
+ );
92
+ ```
87
93
 
88
- ```js
89
- import { baseConfig } from "@zayne-labs/prettier-config";
94
+ ## Plugin Auto-Installation
90
95
 
91
- export default {
92
- ...baseConfig,
93
- printWidth: 120,
94
- semi: true,
95
- };
96
- ```
96
+ This config won't bloat your `node_modules` with plugins you don't use. When you enable a feature (like `astro` or `tailwindcss` for instance), it checks if the required plugins are installed.
97
+ If missing, it will prompt you in the terminal to auto-install them when you run `prettier --write .` cli command.
97
98
 
98
99
  ## License
99
100
 
100
- MIT © Zayne Labs
101
+ MIT © [Zayne Labs](https://github.com/zayne-labs)
@@ -0,0 +1,17 @@
1
+ //#region src/constants/defaults.d.ts
2
+ declare const getDefaultTailwindSettings: () => {
3
+ tailwindAttributes: ["classNames", "classes"];
4
+ tailwindFunctions: ["cnMerge", "cnJoin", "cn", "tv", "tw"];
5
+ tailwindStylesheet: "./tailwind.css";
6
+ } & {
7
+ $inferUnion: "tailwindAttributes" | "tailwindFunctions" | "tailwindStylesheet";
8
+ };
9
+ declare const getDefaultImportSortingOrder: () => {
10
+ css: ".css$";
11
+ main: ["^https?://", "<BUILTIN_MODULES>", "^(bun|jsr|npm):", "<THIRD_PARTY_MODULES>", "^(@/|[#~$%])", "^(?!.*[.]css$)[./].*$"];
12
+ } & {
13
+ $inferUnion: "css" | "main";
14
+ };
15
+ //#endregion
16
+ export { getDefaultImportSortingOrder, getDefaultTailwindSettings };
17
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { n as getDefaultTailwindSettings, t as getDefaultImportSortingOrder } from "../defaults-DCbiIW5Q.js";
2
+
3
+ export { getDefaultImportSortingOrder, getDefaultTailwindSettings };
@@ -0,0 +1,33 @@
1
+ import { defineEnumDeep } from "@zayne-labs/toolkit-type-helpers";
2
+
3
+ //#region src/constants/defaults.ts
4
+ const getDefaultTailwindSettings = () => {
5
+ return defineEnumDeep({
6
+ tailwindAttributes: ["classNames", "classes"],
7
+ tailwindFunctions: [
8
+ "cnMerge",
9
+ "cnJoin",
10
+ "cn",
11
+ "tv",
12
+ "tw"
13
+ ],
14
+ tailwindStylesheet: "./tailwind.css"
15
+ });
16
+ };
17
+ const getDefaultImportSortingOrder = () => {
18
+ return defineEnumDeep({
19
+ css: ".css$",
20
+ main: [
21
+ "^https?://",
22
+ "<BUILTIN_MODULES>",
23
+ "^(bun|jsr|npm):",
24
+ "<THIRD_PARTY_MODULES>",
25
+ "^(@/|[#~$%])",
26
+ "^(?!.*[.]css$)[./].*$"
27
+ ]
28
+ });
29
+ };
30
+
31
+ //#endregion
32
+ export { getDefaultTailwindSettings as n, getDefaultImportSortingOrder as t };
33
+ //# sourceMappingURL=defaults-DCbiIW5Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults-DCbiIW5Q.js","names":[],"sources":["../src/constants/defaults.ts"],"sourcesContent":["import { defineEnumDeep } from \"@zayne-labs/toolkit-type-helpers\";\n\nexport const getDefaultTailwindSettings = () => {\n\treturn defineEnumDeep({\n\t\ttailwindAttributes: [\"classNames\", \"classes\"],\n\t\ttailwindFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\"],\n\t\ttailwindStylesheet: \"./tailwind.css\",\n\t});\n};\n\nexport const getDefaultImportSortingOrder = () => {\n\treturn defineEnumDeep({\n\t\t// CSS files (always last)\n\t\tcss: \".css$\",\n\n\t\tmain: [\n\t\t\t// URLs (e.g., https://example.org)\n\t\t\t\"^https?://\",\n\t\t\t// Protocol imports (node:, bun:, jsr:, npm:, etc.)\n\t\t\t\"<BUILTIN_MODULES>\",\n\t\t\t\"^(bun|jsr|npm):\",\n\t\t\t// Third-party packages\n\t\t\t\"<THIRD_PARTY_MODULES>\",\n\t\t\t// Aliases (@/, #, ~, $, %)\n\t\t\t\"^(@/|[#~$%])\",\n\t\t\t// Relative and absolute paths (excluding CSS)\n\t\t\t\"^(?!.*[.]css$)[./].*$\",\n\t\t],\n\t});\n};\n"],"mappings":";;;AAEA,MAAa,mCAAmC;AAC/C,QAAO,eAAe;EACrB,oBAAoB,CAAC,cAAc,UAAU;EAC7C,mBAAmB;GAAC;GAAW;GAAU;GAAM;GAAM;GAAK;EAC1D,oBAAoB;EACpB,CAAC;;AAGH,MAAa,qCAAqC;AACjD,QAAO,eAAe;EAErB,KAAK;EAEL,MAAM;GAEL;GAEA;GACA;GAEA;GAEA;GAEA;GACA;EACD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,171 +1,13 @@
1
- import { AnyString } from "@zayne-labs/toolkit-type-helpers";
2
- import { Config, Plugin } from "prettier";
1
+ import { a as OptionsTailwindCss, i as OptionsSortImports, n as OptionsAstro, o as ResolvedPrettierConfig, r as OptionsPrettierConfig, t as ExtractOptions } from "./types-B17hDweL.js";
3
2
 
4
- //#region src/types.d.ts
5
- type RestOfAllowedPluginTypes = AnyString | Plugin | URL;
6
- type OptionsClassNames = {
7
- /**
8
- * List of additional attributes that enclose class names.
9
- * The `class` and `className` attributes are always supported.
10
- * @docs [prettier-plugin-classnames#custom-attributes](https://github.com/ony3000/prettier-plugin-classnames#custom-attributes)
11
- */
12
- customAttributes?: string[];
13
- /**
14
- * List of additional functions that enclose class names.
15
- * The `classNames` function is always supported.
16
- * @docs [prettier-plugin-classnames#custom-functions](https://github.com/ony3000/prettier-plugin-classnames#custom-functions)
17
- */
18
- customFunctions?: string[];
19
- /**
20
- * Criterion for ending the class name on each line when replacing with multi-line.
21
- * @default "absolute"
22
- * @docs [prettier-plugin-classnames#ending-position](https://github.com/ony3000/prettier-plugin-classnames#ending-position)
23
- */
24
- endPosition?: "absolute" | "relative";
25
- /**
26
- * Transforms non-expression class names into expression syntax if line wrapping occurs.
27
- * Note: This transformation does not support reversible formatting.
28
- * @default false
29
- * @docs [prettier-plugin-classnames#syntax-transformation](https://github.com/ony3000/prettier-plugin-classnames#syntax-transformation)
30
- */
31
- syntaxTransformation?: boolean;
32
- };
33
- type OptionsTailwindCss = OptionsClassNames & {
34
- plugins?: Array<"prettier-plugin-tailwindcss" | "prettier-plugin-classnames" | "prettier-plugin-merge" | RestOfAllowedPluginTypes>;
35
- /**
36
- * List of attributes to sort classes in. Supports regex patterns.
37
- * @docs [prettier-plugin-tailwindcss#sorting-non-standard-attributes](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#sorting-non-standard-attributes)
38
- */
39
- tailwindAttributes?: string[];
40
- /**
41
- * Path to the Tailwind configuration file (v3).
42
- * @docs [prettier-plugin-tailwindcss#specifying-your-tailwind-javascript-config-path-tailwind-css-v3](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#specifying-your-tailwind-javascript-config-path-tailwind-css-v3)
43
- */
44
- tailwindConfig?: `./${string}`;
45
- /**
46
- * List of functions or tagged templates to sort classes in. Supports regex patterns.
47
- * @docs [prettier-plugin-tailwindcss#sorting-classes-in-function-calls](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#sorting-classes-in-function-calls)
48
- */
49
- tailwindFunctions?: string[];
50
- /**
51
- * Prevent automatic removal of duplicate classes.
52
- * @docs [prettier-plugin-tailwindcss#preserving-duplicate-classes](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#preserving-duplicate-classes)
53
- */
54
- tailwindPreserveDuplicates?: boolean;
55
- /**
56
- * Prevent automatic removal of unnecessary whitespace.
57
- * @docs [prettier-plugin-tailwindcss#preserving-whitespace](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#preserving-whitespace)
58
- */
59
- tailwindPreserveWhitespace?: boolean;
60
- /**
61
- * Path to the CSS entry point (Tailwind CSS v4+).
62
- * @default "./tailwind.css"
63
- * @docs [prettier-plugin-tailwindcss#specifying-your-tailwind-stylesheet-path-tailwind-css-v4](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#specifying-your-tailwind-stylesheet-path-tailwind-css-v4)
64
- */
65
- tailwindStylesheet?: `./${string}`;
66
- };
67
- type OptionsAstro = {
68
- /**
69
- * Enable automatic formatting of attributes to shorthand form (e.g., `<element {name} />`).
70
- * @default false
71
- * @docs [prettier-plugin-astro#astroallowshorthand](https://github.com/withastro/prettier-plugin-astro#astroallowshorthand)
72
- */
73
- astroAllowShorthand?: boolean;
74
- /**
75
- * Skip formatting of JavaScript frontmatter.
76
- * @default false
77
- * @docs [prettier-plugin-astro#astroskipfrontmatter](https://github.com/withastro/prettier-plugin-astro#astroskipfrontmatter)
78
- */
79
- astroSkipFrontmatter?: boolean;
80
- overrides?: Array<
81
- /**
82
- * @docs [prettier-plugin-astro#recommended-configuration](https://github.com/withastro/prettier-plugin-astro#recommended-configuration)
83
- */
84
- {
85
- files: "*.astro";
86
- options: {
87
- parser: "astro";
88
- };
89
- } | NonNullable<Config["overrides"]>[number]>;
90
- plugins?: Array<"prettier-plugin-astro" | RestOfAllowedPluginTypes>;
91
- };
92
- type OptionsSortImports = {
93
- /**
94
- * Regex patterns to control import grouping and order.
95
- * Supports special words: `<BUILTIN_MODULES>`, `<THIRD_PARTY_MODULES>`, `<TYPES>`.
96
- * Use empty strings (`""`) to add blank lines between groups.
97
- * @default ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^[.]"]
98
- * @docs [prettier-plugin-sort-imports#importorder](https://github.com/ianvs/prettier-plugin-sort-imports#importorder)
99
- */
100
- importOrder?: string[];
101
- /**
102
- * Enable case-sensitive sorting within import groups.
103
- * @default false
104
- * @docs [prettier-plugin-sort-imports#importordercasesensitive](https://github.com/ianvs/prettier-plugin-sort-imports#importordercasesensitive)
105
- */
106
- importOrderCaseSensitive?: boolean;
107
- /**
108
- * Babel parser plugins to understand file syntax (e.g., `["typescript", "jsx"]`).
109
- * Pass plugin options as JSON: `["decorators", { "decoratorsBeforeExport": true }]`.
110
- * @default ["typescript", "jsx"]
111
- * @docs [prettier-plugin-sort-imports#importorderparserplugins](https://github.com/ianvs/prettier-plugin-sort-imports#importorderparserplugins)
112
- */
113
- importOrderParserPlugins?: string[];
114
- /**
115
- * Regex patterns for side-effect imports that are safe to reorder.
116
- * By default, side-effect imports are not reordered. Use `^pattern$` for exact matches.
117
- * @default []
118
- * @docs [prettier-plugin-sort-imports#importordersafesideeffects](https://github.com/ianvs/prettier-plugin-sort-imports#importordersafesideeffects)
119
- */
120
- importOrderSafeSideEffects?: string[];
121
- /**
122
- * TypeScript version to enable modern import syntax features (e.g., mixed type/value imports).
123
- * @default "1.0.0"
124
- * @docs [prettier-plugin-sort-imports#importordertypescriptversion](https://github.com/ianvs/prettier-plugin-sort-imports#importordertypescriptversion)
125
- */
126
- importOrderTypeScriptVersion?: string;
127
- plugins?: Array<"@ianvs/prettier-plugin-sort-imports" | RestOfAllowedPluginTypes>;
128
- };
129
- interface OptionsPrettierConfig {
130
- /**
131
- * Astro configuration
132
- * @default false
133
- * @docs [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro#configuration)
134
- */
135
- astro?: boolean | OptionsAstro;
136
- /**
137
- * Base Prettier configuration with opinionated defaults.
138
- * Includes settings for tabs, print width, quotes, trailing commas, and experimental features.
139
- * @default true
140
- */
141
- base?: boolean | Config;
142
- /**
143
- * Sort imports configuration
144
- * @default false
145
- * @docs [prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports#configuration)
146
- */
147
- sortImports?: boolean | OptionsSortImports;
148
- /**
149
- * Tailwind CSS configuration
150
- * @default false
151
- * @docs
152
- * - [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
153
- * - [prettier-plugin-classnames](https://github.com/ony3000/prettier-plugin-classnames)
154
- * - [prettier-plugin-merge](https://github.com/ony3000/prettier-plugin-merge)
155
- */
156
- tailwindcss?: boolean | OptionsTailwindCss;
157
- }
158
- type ResolvedPrettierConfig = Config & OptionsAstro & OptionsSortImports & OptionsTailwindCss & Record<string, unknown>;
159
- type ExtractOptions<TUnion> = Extract<TUnion, object>;
160
- //#endregion
161
3
  //#region src/configs/astro.d.ts
162
- declare const astro: (options: ExtractOptions<OptionsPrettierConfig["astro"]>) => typeof options;
4
+ declare const astro: (options: ExtractOptions<OptionsPrettierConfig["astro"]>) => Promise<typeof options>;
163
5
  //#endregion
164
6
  //#region src/configs/base.d.ts
165
7
  declare const base: (options: ExtractOptions<OptionsPrettierConfig["base"]>) => typeof options;
166
8
  //#endregion
167
9
  //#region src/configs/tailwindcss.d.ts
168
- declare const tailwindcss: (options: ExtractOptions<OptionsPrettierConfig["tailwindcss"]>) => typeof options;
10
+ declare const tailwindcss: (options: ExtractOptions<OptionsPrettierConfig["tailwindcss"]>) => Promise<typeof options>;
169
11
  //#endregion
170
12
  //#region src/factory.d.ts
171
13
  /**
@@ -186,12 +28,12 @@ declare const tailwindcss: (options: ExtractOptions<OptionsPrettierConfig["tailw
186
28
  * },
187
29
  * // Extra config to merge (optional)
188
30
  * {
189
- * semi: false,
31
+ * useTabs: false,
190
32
  * }
191
33
  * );
192
34
  * ```
193
35
  */
194
- declare const zayne: (options?: OptionsPrettierConfig, ...extraConfigs: ResolvedPrettierConfig[]) => ResolvedPrettierConfig;
36
+ declare const zayne: (options?: OptionsPrettierConfig, ...extraConfigs: ResolvedPrettierConfig[]) => Promise<ResolvedPrettierConfig>;
195
37
  //#endregion
196
38
  export { ExtractOptions, OptionsAstro, OptionsPrettierConfig, OptionsSortImports, OptionsTailwindCss, ResolvedPrettierConfig, astro, base, tailwindcss, zayne };
197
39
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,14 +1,17 @@
1
- import { isArray, isObject } from "@zayne-labs/toolkit-type-helpers";
1
+ import { a as resolveOptions, n as ensurePackages, t as combineConfigs } from "./utils-CEqE7-_1.js";
2
+ import { n as getDefaultTailwindSettings, t as getDefaultImportSortingOrder } from "./defaults-DCbiIW5Q.js";
2
3
 
3
4
  //#region src/configs/astro.ts
4
- const astro = (options) => {
5
+ const astro = async (options) => {
6
+ const necessaryPlugins = ["prettier-plugin-astro"];
7
+ await ensurePackages(necessaryPlugins);
5
8
  return {
6
9
  ...options,
7
10
  overrides: [{
8
11
  files: "*.astro",
9
12
  options: { parser: "astro" }
10
13
  }, ...options.overrides ?? []],
11
- plugins: ["prettier-plugin-astro", ...options.plugins ?? []]
14
+ plugins: [...necessaryPlugins, ...options.plugins ?? []]
12
15
  };
13
16
  };
14
17
 
@@ -30,87 +33,46 @@ const base = (options) => {
30
33
 
31
34
  //#endregion
32
35
  //#region src/configs/tailwindcss.ts
33
- const tailwindcss = (options) => {
36
+ const tailwindcss = async (options) => {
37
+ const necessaryPlugins = {
38
+ first: ["prettier-plugin-tailwindcss", "prettier-plugin-classnames"],
39
+ last: ["prettier-plugin-merge"]
40
+ };
41
+ await ensurePackages([...necessaryPlugins.first, ...necessaryPlugins.last]);
42
+ const tailwindSettings = getDefaultTailwindSettings();
34
43
  return {
35
- tailwindStylesheet: "./tailwind.css",
44
+ tailwindStylesheet: tailwindSettings.tailwindStylesheet,
36
45
  ...options,
37
- customAttributes: [
38
- "classNames",
39
- "classes",
40
- ...options.customAttributes ?? []
41
- ],
42
- customFunctions: [
43
- "cnMerge",
44
- "cnJoin",
45
- "cn",
46
- "tv",
47
- "tw",
48
- ...options.customFunctions ?? []
49
- ],
46
+ customAttributes: [...tailwindSettings.tailwindAttributes, ...options.customAttributes ?? []],
47
+ customFunctions: [...tailwindSettings.tailwindFunctions, ...options.customFunctions ?? []],
50
48
  plugins: [
51
- "prettier-plugin-tailwindcss",
52
- "prettier-plugin-classnames",
49
+ ...necessaryPlugins.first,
53
50
  ...options.plugins ?? [],
54
- "prettier-plugin-merge"
51
+ ...necessaryPlugins.last
55
52
  ],
56
- tailwindAttributes: [
57
- "classNames",
58
- "classes",
59
- ...options.tailwindAttributes ?? []
60
- ],
61
- tailwindFunctions: [
62
- "cnMerge",
63
- "cnJoin",
64
- "cn",
65
- "tv",
66
- "tw",
67
- ...options.tailwindFunctions ?? []
68
- ]
53
+ tailwindAttributes: [...tailwindSettings.tailwindAttributes, ...options.tailwindAttributes ?? []],
54
+ tailwindFunctions: [...tailwindSettings.tailwindFunctions, ...options.tailwindFunctions ?? []]
69
55
  };
70
56
  };
71
57
 
72
58
  //#endregion
73
59
  //#region src/configs/sort.ts
74
- const sortImports = (options) => {
60
+ const sortImports = async (options) => {
61
+ const necessaryPlugins = ["@ianvs/prettier-plugin-sort-imports"];
62
+ await ensurePackages(necessaryPlugins);
63
+ const sortingOrder = getDefaultImportSortingOrder();
75
64
  return {
76
65
  ...options,
77
66
  importOrder: [
78
- "^https?://",
79
- "<BUILTIN_MODULES>",
80
- "^(bun|jsr|npm):",
81
- "<THIRD_PARTY_MODULES>",
82
- "^(@/|[#~$%])",
83
- "^(?!.*[.]css$)[./].*$",
67
+ ...sortingOrder.main,
84
68
  ...options.importOrder ?? [],
85
- ".css$"
69
+ sortingOrder.css
86
70
  ],
87
- importOrderSafeSideEffects: [".css$", ...options.importOrderSafeSideEffects ?? []],
88
- plugins: ["@ianvs/prettier-plugin-sort-imports", ...options.plugins ?? []]
71
+ importOrderSafeSideEffects: [sortingOrder.css, ...options.importOrderSafeSideEffects ?? []],
72
+ plugins: [...necessaryPlugins, ...options.plugins ?? []]
89
73
  };
90
74
  };
91
75
 
92
- //#endregion
93
- //#region src/utils.ts
94
- /**
95
- * @description Resolves a boolean or object option to an object.
96
- * If the option is an object, it returns it as-is. Otherwise, returns an empty object.
97
- */
98
- const resolveOptions = (option) => {
99
- return isObject(option) ? option : {};
100
- };
101
- /**
102
- * @description Merges two Prettier configurations.
103
- * Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.
104
- */
105
- const mergeTwoConfigs = (formerConfig, latterConfig) => {
106
- const configAccumulator = { ...formerConfig };
107
- for (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {
108
- const accumulatedConfigValue = configAccumulator[latterConfigKey];
109
- configAccumulator[latterConfigKey] = isArray(latterConfigValue) && isArray(accumulatedConfigValue) ? [...accumulatedConfigValue, ...latterConfigValue] : latterConfigValue;
110
- }
111
- return configAccumulator;
112
- };
113
-
114
76
  //#endregion
115
77
  //#region src/factory.ts
116
78
  /**
@@ -131,28 +93,21 @@ const mergeTwoConfigs = (formerConfig, latterConfig) => {
131
93
  * },
132
94
  * // Extra config to merge (optional)
133
95
  * {
134
- * semi: false,
96
+ * useTabs: false,
135
97
  * }
136
98
  * );
137
99
  * ```
138
100
  */
139
- const zayne = (options = {}, ...extraConfigs) => {
140
- const { astro: enabledAstro = false, base: enabledBase = true, sortImports: enabledSortImports = false, tailwindcss: enabledTailwindcss = false } = options;
141
- const configArray = [
101
+ const zayne = async (options = {}, ...extraConfigs) => {
102
+ const { astro: enabledAstro = false, base: enabledBase = true, sortImports: enabledSortImports = true, tailwindcss: enabledTailwindcss = false } = options;
103
+ return await combineConfigs([
142
104
  enabledBase ? base(resolveOptions(enabledBase)) : void 0,
143
105
  enabledAstro ? astro(resolveOptions(enabledAstro)) : void 0,
144
106
  enabledSortImports ? sortImports(resolveOptions(enabledSortImports)) : void 0,
145
107
  ...extraConfigs,
146
108
  enabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : void 0
147
- ];
148
- let resolvedConfig = {};
149
- for (const config of configArray) {
150
- if (!config) continue;
151
- resolvedConfig = mergeTwoConfigs(resolvedConfig, config);
152
- }
153
- return resolvedConfig;
109
+ ]);
154
110
  };
155
- zayne({}, {});
156
111
 
157
112
  //#endregion
158
113
  export { astro, base, tailwindcss, zayne };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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/configs/sort.ts","../src/utils.ts","../src/factory.ts"],"sourcesContent":["import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\n\nexport const astro = (options: ExtractOptions<OptionsPrettierConfig[\"astro\"]>): typeof options => {\n\treturn {\n\t\t...options,\n\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, OptionsPrettierConfig } from \"@/types\";\n\nexport const base = (options: ExtractOptions<OptionsPrettierConfig[\"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\n\t\t...options,\n\t};\n};\n","import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\n\nexport const tailwindcss = (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"tailwindcss\"]>\n): typeof options => {\n\treturn {\n\t\ttailwindStylesheet: \"./tailwind.css\",\n\n\t\t...options,\n\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\n\t\t\t...(options.plugins ?? []),\n\n\t\t\t/**\n\t\t\t * This plugin must always come last\n\t\t\t * @see https://github.com/ony3000/prettier-plugin-merge#why-prettier-plugin-merge\n\t\t\t */\n\t\t\t\"prettier-plugin-merge\",\n\t\t],\n\t\ttailwindAttributes: [\"classNames\", \"classes\", ...(options.tailwindAttributes ?? [])],\n\t\ttailwindFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\", ...(options.tailwindFunctions ?? [])],\n\t};\n};\n","import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\n\nexport const sortImports = (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"sortImports\"]>\n): typeof options => {\n\treturn {\n\t\t...options,\n\n\t\timportOrder: [\n\t\t\t// URLs (e.g., https://example.org)\n\t\t\t\"^https?://\",\n\t\t\t// Protocol imports (node:, bun:, jsr:, npm:, etc.)\n\t\t\t\"<BUILTIN_MODULES>\",\n\t\t\t\"^(bun|jsr|npm):\",\n\t\t\t// Third-party packages\n\t\t\t\"<THIRD_PARTY_MODULES>\",\n\t\t\t// Aliases (@/, #, ~, $, %)\n\t\t\t\"^(@/|[#~$%])\",\n\t\t\t// Relative and absolute paths (excluding CSS)\n\t\t\t\"^(?!.*[.]css$)[./].*$\",\n\n\t\t\t...(options.importOrder ?? []),\n\n\t\t\t// CSS files (always last)\n\t\t\t\".css$\",\n\t\t],\n\t\timportOrderSafeSideEffects: [\".css$\", ...(options.importOrderSafeSideEffects ?? [])],\n\n\t\tplugins: [\"@ianvs/prettier-plugin-sort-imports\", ...(options.plugins ?? [])],\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 { sortImports } from \"./configs/sort\";\nimport type { OptionsPrettierConfig, 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: OptionsPrettierConfig = {}, ...extraConfigs: ResolvedPrettierConfig[]) => {\n\tconst {\n\t\tastro: enabledAstro = false,\n\t\tbase: enabledBase = true,\n\t\tsortImports: enabledSortImports = false,\n\t\ttailwindcss: enabledTailwindcss = false,\n\t} = options;\n\n\tconst configArray: Array<ResolvedPrettierConfig | undefined> = [\n\t\tenabledBase ? base(resolveOptions(enabledBase)) : undefined,\n\t\tenabledAstro ? astro(resolveOptions(enabledAstro)) : undefined,\n\t\tenabledSortImports ? sortImports(resolveOptions(enabledSortImports)) : undefined,\n\n\t\t...extraConfigs,\n\n\t\t/**\n\t\t * Tailwind plugin most always be the last one to avoid conflicts\n\t\t * @see https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins\n\t\t */\n\t\tenabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : undefined,\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\nzayne({}, {});\n"],"mappings":";;;AAEA,MAAa,SAAS,YAA4E;AACjG,QAAO;EACN,GAAG;EAEH,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;;;;;ACZF,MAAa,QAAQ,YAA2E;AAC/F,QAAO;EACN,8BAA8B;EAC9B,uBAAuB;EACvB,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,UAAU;EACV,eAAe;EACf,SAAS;EAET,GAAG;EACH;;;;;ACZF,MAAa,eACZ,YACoB;AACpB,QAAO;EACN,oBAAoB;EAEpB,GAAG;EAEH,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;GAEA,GAAI,QAAQ,WAAW,EAAE;GAMzB;GACA;EACD,oBAAoB;GAAC;GAAc;GAAW,GAAI,QAAQ,sBAAsB,EAAE;GAAE;EACpF,mBAAmB;GAAC;GAAW;GAAU;GAAM;GAAM;GAAM,GAAI,QAAQ,qBAAqB,EAAE;GAAE;EAChG;;;;;ACxBF,MAAa,eACZ,YACoB;AACpB,QAAO;EACN,GAAG;EAEH,aAAa;GAEZ;GAEA;GACA;GAEA;GAEA;GAEA;GAEA,GAAI,QAAQ,eAAe,EAAE;GAG7B;GACA;EACD,4BAA4B,CAAC,SAAS,GAAI,QAAQ,8BAA8B,EAAE,CAAE;EAEpF,SAAS,CAAC,uCAAuC,GAAI,QAAQ,WAAW,EAAE,CAAE;EAC5E;;;;;;;;;ACtBF,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACJR,MAAa,SAAS,UAAiC,EAAE,EAAE,GAAG,iBAA2C;CACxG,MAAM,EACL,OAAO,eAAe,OACtB,MAAM,cAAc,MACpB,aAAa,qBAAqB,OAClC,aAAa,qBAAqB,UAC/B;CAEJ,MAAMC,cAAyD;EAC9D,cAAc,KAAK,eAAe,YAAY,CAAC,GAAG;EAClD,eAAe,MAAM,eAAe,aAAa,CAAC,GAAG;EACrD,qBAAqB,YAAY,eAAe,mBAAmB,CAAC,GAAG;EAEvE,GAAG;EAMH,qBAAqB,YAAY,eAAe,mBAAmB,CAAC,GAAG;EACvE;CAED,IAAIC,iBAAyC,EAAE;AAE/C,MAAK,MAAM,UAAU,aAAa;AACjC,MAAI,CAAC,OAAQ;AAEb,mBAAiB,gBAAgB,gBAAgB,OAAO;;AAGzD,QAAO;;AAGR,MAAM,EAAE,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/configs/astro.ts","../src/configs/base.ts","../src/configs/tailwindcss.ts","../src/configs/sort.ts","../src/factory.ts"],"sourcesContent":["import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const astro = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"astro\"]>\n): Promise<typeof options> => {\n\tconst necessaryPlugins = [\"prettier-plugin-astro\"];\n\n\tawait ensurePackages(necessaryPlugins);\n\n\treturn {\n\t\t...options,\n\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\n\t\tplugins: [...necessaryPlugins, ...(options.plugins ?? [])],\n\t};\n};\n","import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\n\nexport const base = (options: ExtractOptions<OptionsPrettierConfig[\"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\n\t\t...options,\n\t};\n};\n","import { getDefaultTailwindSettings } from \"@/constants/defaults\";\nimport type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const tailwindcss = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"tailwindcss\"]>\n): Promise<typeof options> => {\n\tconst necessaryPlugins = {\n\t\tfirst: [\"prettier-plugin-tailwindcss\", \"prettier-plugin-classnames\"],\n\t\tlast: [\"prettier-plugin-merge\"],\n\t} as const;\n\n\tawait ensurePackages([...necessaryPlugins.first, ...necessaryPlugins.last]);\n\n\tconst tailwindSettings = getDefaultTailwindSettings();\n\n\treturn {\n\t\ttailwindStylesheet: tailwindSettings.tailwindStylesheet,\n\n\t\t...options,\n\n\t\tcustomAttributes: [...tailwindSettings.tailwindAttributes, ...(options.customAttributes ?? [])],\n\t\tcustomFunctions: [...tailwindSettings.tailwindFunctions, ...(options.customFunctions ?? [])],\n\n\t\tplugins: [\n\t\t\t...necessaryPlugins.first,\n\n\t\t\t...(options.plugins ?? []),\n\n\t\t\t/**\n\t\t\t * The 'merge' plugin must always come last\n\t\t\t * @see https://github.com/ony3000/prettier-plugin-merge#why-prettier-plugin-merge\n\t\t\t */\n\t\t\t...necessaryPlugins.last,\n\t\t],\n\n\t\ttailwindAttributes: [...tailwindSettings.tailwindAttributes, ...(options.tailwindAttributes ?? [])],\n\t\ttailwindFunctions: [...tailwindSettings.tailwindFunctions, ...(options.tailwindFunctions ?? [])],\n\t};\n};\n","import { getDefaultImportSortingOrder } from \"@/constants/defaults\";\nimport type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const sortImports = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"sortImports\"]>\n): Promise<typeof options> => {\n\tconst necessaryPlugins = [\"@ianvs/prettier-plugin-sort-imports\"];\n\n\tawait ensurePackages(necessaryPlugins);\n\n\tconst sortingOrder = getDefaultImportSortingOrder();\n\n\treturn {\n\t\t...options,\n\n\t\timportOrder: [...sortingOrder.main, ...(options.importOrder ?? []), sortingOrder.css],\n\t\timportOrderSafeSideEffects: [sortingOrder.css, ...(options.importOrderSafeSideEffects ?? [])],\n\n\t\tplugins: [...necessaryPlugins, ...(options.plugins ?? [])],\n\t};\n};\n","import type { Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { astro, base, tailwindcss } from \"./configs\";\nimport { sortImports } from \"./configs/sort\";\nimport type { OptionsPrettierConfig, ResolvedPrettierConfig } from \"./types\";\nimport { combineConfigs, 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 * useTabs: false,\n * }\n * );\n * ```\n */\nexport const zayne = async (\n\toptions: OptionsPrettierConfig = {},\n\t...extraConfigs: ResolvedPrettierConfig[]\n) => {\n\tconst {\n\t\tastro: enabledAstro = false,\n\t\tbase: enabledBase = true,\n\t\tsortImports: enabledSortImports = true,\n\t\ttailwindcss: enabledTailwindcss = false,\n\t} = options;\n\n\tconst configArray: Array<Awaitable<ResolvedPrettierConfig | undefined>> = [\n\t\tenabledBase ? base(resolveOptions(enabledBase)) : undefined,\n\t\tenabledAstro ? astro(resolveOptions(enabledAstro)) : undefined,\n\t\tenabledSortImports ? sortImports(resolveOptions(enabledSortImports)) : undefined,\n\n\t\t...extraConfigs,\n\n\t\t/**\n\t\t * Tailwind plugin most always be the last one to avoid conflicts\n\t\t * @see https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins\n\t\t */\n\t\tenabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : undefined,\n\t];\n\n\tconst accumulatedConfig = await combineConfigs(configArray);\n\n\treturn accumulatedConfig;\n};\n"],"mappings":";;;;AAGA,MAAa,QAAQ,OACpB,YAC6B;CAC7B,MAAM,mBAAmB,CAAC,wBAAwB;AAElD,OAAM,eAAe,iBAAiB;AAEtC,QAAO;EACN,GAAG;EAEH,WAAW,CACV;GACC,OAAO;GACP,SAAS,EAAE,QAAQ,SAAS;GAC5B,EACD,GAAI,QAAQ,aAAa,EAAE,CAC3B;EAED,SAAS,CAAC,GAAG,kBAAkB,GAAI,QAAQ,WAAW,EAAE,CAAE;EAC1D;;;;;ACpBF,MAAa,QAAQ,YAA2E;AAC/F,QAAO;EACN,8BAA8B;EAC9B,uBAAuB;EACvB,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,UAAU;EACV,eAAe;EACf,SAAS;EAET,GAAG;EACH;;;;;ACVF,MAAa,cAAc,OAC1B,YAC6B;CAC7B,MAAM,mBAAmB;EACxB,OAAO,CAAC,+BAA+B,6BAA6B;EACpE,MAAM,CAAC,wBAAwB;EAC/B;AAED,OAAM,eAAe,CAAC,GAAG,iBAAiB,OAAO,GAAG,iBAAiB,KAAK,CAAC;CAE3E,MAAM,mBAAmB,4BAA4B;AAErD,QAAO;EACN,oBAAoB,iBAAiB;EAErC,GAAG;EAEH,kBAAkB,CAAC,GAAG,iBAAiB,oBAAoB,GAAI,QAAQ,oBAAoB,EAAE,CAAE;EAC/F,iBAAiB,CAAC,GAAG,iBAAiB,mBAAmB,GAAI,QAAQ,mBAAmB,EAAE,CAAE;EAE5F,SAAS;GACR,GAAG,iBAAiB;GAEpB,GAAI,QAAQ,WAAW,EAAE;GAMzB,GAAG,iBAAiB;GACpB;EAED,oBAAoB,CAAC,GAAG,iBAAiB,oBAAoB,GAAI,QAAQ,sBAAsB,EAAE,CAAE;EACnG,mBAAmB,CAAC,GAAG,iBAAiB,mBAAmB,GAAI,QAAQ,qBAAqB,EAAE,CAAE;EAChG;;;;;AClCF,MAAa,cAAc,OAC1B,YAC6B;CAC7B,MAAM,mBAAmB,CAAC,sCAAsC;AAEhE,OAAM,eAAe,iBAAiB;CAEtC,MAAM,eAAe,8BAA8B;AAEnD,QAAO;EACN,GAAG;EAEH,aAAa;GAAC,GAAG,aAAa;GAAM,GAAI,QAAQ,eAAe,EAAE;GAAG,aAAa;GAAI;EACrF,4BAA4B,CAAC,aAAa,KAAK,GAAI,QAAQ,8BAA8B,EAAE,CAAE;EAE7F,SAAS,CAAC,GAAG,kBAAkB,GAAI,QAAQ,WAAW,EAAE,CAAE;EAC1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACSF,MAAa,QAAQ,OACpB,UAAiC,EAAE,EACnC,GAAG,iBACC;CACJ,MAAM,EACL,OAAO,eAAe,OACtB,MAAM,cAAc,MACpB,aAAa,qBAAqB,MAClC,aAAa,qBAAqB,UAC/B;AAkBJ,QAF0B,MAAM,eAd0C;EACzE,cAAc,KAAK,eAAe,YAAY,CAAC,GAAG;EAClD,eAAe,MAAM,eAAe,aAAa,CAAC,GAAG;EACrD,qBAAqB,YAAY,eAAe,mBAAmB,CAAC,GAAG;EAEvE,GAAG;EAMH,qBAAqB,YAAY,eAAe,mBAAmB,CAAC,GAAG;EACvE,CAE0D"}
@@ -0,0 +1,177 @@
1
+ import { AnyString } from "@zayne-labs/toolkit-type-helpers";
2
+ import { Config, Plugin } from "prettier";
3
+
4
+ //#region src/types.d.ts
5
+ type RestOfAllowedPluginTypes = AnyString | Plugin | URL;
6
+ type OptionsClassNames = {
7
+ /**
8
+ * List of additional attributes that enclose class names.
9
+ * The `class` and `className` attributes are always supported.
10
+ * @docs [prettier-plugin-classnames#custom-attributes](https://github.com/ony3000/prettier-plugin-classnames#custom-attributes)
11
+ */
12
+ customAttributes?: string[];
13
+ /**
14
+ * List of additional functions that enclose class names.
15
+ * The `classNames` function is always supported.
16
+ * @docs [prettier-plugin-classnames#custom-functions](https://github.com/ony3000/prettier-plugin-classnames#custom-functions)
17
+ */
18
+ customFunctions?: string[];
19
+ /**
20
+ * Criterion for ending the class name on each line when replacing with multi-line.
21
+ * @default "absolute"
22
+ * @docs [prettier-plugin-classnames#ending-position](https://github.com/ony3000/prettier-plugin-classnames#ending-position)
23
+ */
24
+ endPosition?: "absolute" | "relative";
25
+ /**
26
+ * Transforms non-expression class names into expression syntax if line wrapping occurs.
27
+ * Note: This transformation does not support reversible formatting.
28
+ * @default false
29
+ * @docs [prettier-plugin-classnames#syntax-transformation](https://github.com/ony3000/prettier-plugin-classnames#syntax-transformation)
30
+ */
31
+ syntaxTransformation?: boolean;
32
+ };
33
+ type OptionsTailwindCss = OptionsClassNames & {
34
+ plugins?: Array<"prettier-plugin-tailwindcss" | "prettier-plugin-classnames" | "prettier-plugin-merge" | RestOfAllowedPluginTypes>;
35
+ /**
36
+ * List of attributes to sort classes in. Supports regex patterns.
37
+ * @docs [prettier-plugin-tailwindcss#sorting-non-standard-attributes](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#sorting-non-standard-attributes)
38
+ */
39
+ tailwindAttributes?: string[];
40
+ /**
41
+ * Path to the Tailwind configuration file (v3).
42
+ * @docs [prettier-plugin-tailwindcss#specifying-your-tailwind-javascript-config-path-tailwind-css-v3](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#specifying-your-tailwind-javascript-config-path-tailwind-css-v3)
43
+ */
44
+ tailwindConfig?: `./${string}`;
45
+ /**
46
+ * List of functions or tagged templates to sort classes in. Supports regex patterns.
47
+ * @docs [prettier-plugin-tailwindcss#sorting-classes-in-function-calls](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#sorting-classes-in-function-calls)
48
+ */
49
+ tailwindFunctions?: string[];
50
+ /**
51
+ * Prevent automatic removal of duplicate classes.
52
+ * @docs [prettier-plugin-tailwindcss#preserving-duplicate-classes](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#preserving-duplicate-classes)
53
+ */
54
+ tailwindPreserveDuplicates?: boolean;
55
+ /**
56
+ * Prevent automatic removal of unnecessary whitespace.
57
+ * @docs [prettier-plugin-tailwindcss#preserving-whitespace](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#preserving-whitespace)
58
+ */
59
+ tailwindPreserveWhitespace?: boolean;
60
+ /**
61
+ * Path to the CSS entry point (Tailwind CSS v4+).
62
+ * @default "./tailwind.css"
63
+ * @docs [prettier-plugin-tailwindcss#specifying-your-tailwind-stylesheet-path-tailwind-css-v4](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#specifying-your-tailwind-stylesheet-path-tailwind-css-v4)
64
+ */
65
+ tailwindStylesheet?: `./${string}`;
66
+ };
67
+ type OptionsAstro = {
68
+ /**
69
+ * Enable automatic formatting of attributes to shorthand form (e.g., `<element {name} />`).
70
+ * @default false
71
+ * @docs [prettier-plugin-astro#astroallowshorthand](https://github.com/withastro/prettier-plugin-astro#astroallowshorthand)
72
+ */
73
+ astroAllowShorthand?: boolean;
74
+ /**
75
+ * Skip formatting of JavaScript frontmatter.
76
+ * @default false
77
+ * @docs [prettier-plugin-astro#astroskipfrontmatter](https://github.com/withastro/prettier-plugin-astro#astroskipfrontmatter)
78
+ */
79
+ astroSkipFrontmatter?: boolean;
80
+ overrides?: Array<
81
+ /**
82
+ * @docs [prettier-plugin-astro#recommended-configuration](https://github.com/withastro/prettier-plugin-astro#recommended-configuration)
83
+ */
84
+ {
85
+ files: "*.astro";
86
+ options: {
87
+ parser: "astro";
88
+ };
89
+ } | NonNullable<Config["overrides"]>[number]>;
90
+ plugins?: Array<"prettier-plugin-astro" | RestOfAllowedPluginTypes>;
91
+ };
92
+ type OptionsSortImports = {
93
+ /**
94
+ * Regex patterns to control import grouping and order.
95
+ * Supports special words: `<BUILTIN_MODULES>`, `<THIRD_PARTY_MODULES>`, `<TYPES>`.
96
+ * Use empty strings (`""`) to add blank lines between groups.
97
+ * @default ["^https?://", "<BUILTIN_MODULES>", "^(bun|jsr|npm):", "<THIRD_PARTY_MODULES>", "^(@/|[#~$%])", "^(?!.*[.]css$)[./].*$", ".css$"]
98
+ * @docs [prettier-plugin-sort-imports#importorder](https://github.com/ianvs/prettier-plugin-sort-imports#importorder)
99
+ */
100
+ importOrder?: string[];
101
+ /**
102
+ * Enable case-sensitive sorting within import groups.
103
+ * @default false
104
+ * @docs [prettier-plugin-sort-imports#importordercasesensitive](https://github.com/ianvs/prettier-plugin-sort-imports#importordercasesensitive)
105
+ */
106
+ importOrderCaseSensitive?: boolean;
107
+ /**
108
+ * Babel parser plugins to understand file syntax (e.g., `["typescript", "jsx"]`).
109
+ * Pass plugin options as JSON: `["decorators", { "decoratorsBeforeExport": true }]`.
110
+ * @default ["typescript", "jsx"]
111
+ * @docs [prettier-plugin-sort-imports#importorderparserplugins](https://github.com/ianvs/prettier-plugin-sort-imports#importorderparserplugins)
112
+ */
113
+ importOrderParserPlugins?: string[];
114
+ /**
115
+ * Regex patterns for side-effect imports that are safe to reorder.
116
+ * By default, side-effect imports are not reordered. Use `^pattern$` for exact matches.
117
+ * @default [".css$"]
118
+ * @docs [prettier-plugin-sort-imports#importordersafesideeffects](https://github.com/ianvs/prettier-plugin-sort-imports#importordersafesideeffects)
119
+ */
120
+ importOrderSafeSideEffects?: string[];
121
+ /**
122
+ * TypeScript version to enable modern import syntax features (e.g., mixed type/value imports).
123
+ * @default "1.0.0"
124
+ * @docs [prettier-plugin-sort-imports#importordertypescriptversion](https://github.com/ianvs/prettier-plugin-sort-imports#importordertypescriptversion)
125
+ */
126
+ importOrderTypeScriptVersion?: string;
127
+ plugins?: Array<"@ianvs/prettier-plugin-sort-imports" | RestOfAllowedPluginTypes>;
128
+ };
129
+ interface OptionsPrettierConfig {
130
+ /**
131
+ * Astro configuration
132
+ *
133
+ * Requires installing:
134
+ * - `prettier-plugin-astro`
135
+ *
136
+ * @default false
137
+ * @docs [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro#configuration)
138
+ */
139
+ astro?: boolean | OptionsAstro;
140
+ /**
141
+ * Base Prettier configuration with opinionated defaults.
142
+ * Includes settings for tabs, print width, quotes, trailing commas, and experimental features.
143
+ *
144
+ * @default true
145
+ */
146
+ base?: boolean | Config;
147
+ /**
148
+ * Sort imports configuration
149
+ *
150
+ * Requires installing:
151
+ * - `prettier-plugin-sort-imports`
152
+ *
153
+ * @default true
154
+ * @docs [prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports#configuration)
155
+ */
156
+ sortImports?: boolean | OptionsSortImports;
157
+ /**
158
+ * Tailwind CSS configuration
159
+ *
160
+ * Requires installing:
161
+ * - `prettier-plugin-tailwindcss`
162
+ * - `prettier-plugin-classnames`
163
+ * - `prettier-plugin-merge`
164
+ *
165
+ * @default false
166
+ * @docs
167
+ * - [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
168
+ * - [prettier-plugin-classnames](https://github.com/ony3000/prettier-plugin-classnames)
169
+ * - [prettier-plugin-merge](https://github.com/ony3000/prettier-plugin-merge)
170
+ */
171
+ tailwindcss?: boolean | OptionsTailwindCss;
172
+ }
173
+ type ResolvedPrettierConfig = Config & OptionsAstro & OptionsSortImports & OptionsTailwindCss & Record<string, unknown>;
174
+ type ExtractOptions<TUnion> = Extract<TUnion, object>;
175
+ //#endregion
176
+ export { OptionsTailwindCss as a, OptionsSortImports as i, OptionsAstro as n, ResolvedPrettierConfig as o, OptionsPrettierConfig as r, ExtractOptions as t };
177
+ //# sourceMappingURL=types-B17hDweL.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { isArray, isObject } from "@zayne-labs/toolkit-type-helpers";
3
+ import { isPackageExists } from "local-pkg";
4
+
5
+ //#region src/utils.ts
6
+ /**
7
+ * @description Resolves a boolean or object option to an object.
8
+ * If the option is an object, it returns it as-is. Otherwise, returns an empty object.
9
+ */
10
+ const resolveOptions = (option) => {
11
+ return isObject(option) ? option : {};
12
+ };
13
+ /**
14
+ * @description Merges two Prettier configurations.
15
+ * Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.
16
+ */
17
+ const mergeTwoConfigs = (formerConfig, latterConfig) => {
18
+ const configAccumulator = { ...formerConfig };
19
+ for (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {
20
+ const accumulatedConfigValue = configAccumulator[latterConfigKey];
21
+ configAccumulator[latterConfigKey] = isArray(latterConfigValue) && isArray(accumulatedConfigValue) ? [...accumulatedConfigValue, ...latterConfigValue] : latterConfigValue;
22
+ }
23
+ return configAccumulator;
24
+ };
25
+ const combineConfigs = async (configArray) => {
26
+ const resolvedConfigArray = await Promise.all(configArray);
27
+ let accumulatedConfig = {};
28
+ for (const config of resolvedConfigArray) {
29
+ if (!config) continue;
30
+ accumulatedConfig = mergeTwoConfigs(accumulatedConfig, config);
31
+ }
32
+ return accumulatedConfig;
33
+ };
34
+ const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
35
+ const isCwdInScope = isPackageExists("@zayne-labs/prettier-config");
36
+ const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
37
+ /**
38
+ * @description
39
+ * - Ensures that packages are installed in the current scope.
40
+ * - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,
41
+ * and the user is in the same scope as this package, then prompt the user to
42
+ * install the packages.
43
+ *
44
+ * @param packages - The packages to ensure are installed.
45
+ */
46
+ const ensurePackages = async (packages) => {
47
+ if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
48
+ const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
49
+ if (nonExistingPackages.length === 0) return;
50
+ if (await (await import("@clack/prompts")).confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) await (await import("@antfu/install-pkg")).installPackage(nonExistingPackages, { dev: true });
51
+ };
52
+
53
+ //#endregion
54
+ export { resolveOptions as a, mergeTwoConfigs as i, ensurePackages as n, isPackageInScope as r, combineConfigs as t };
55
+ //# sourceMappingURL=utils-CEqE7-_1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-CEqE7-_1.js","names":["configAccumulator: ResolvedPrettierConfig","accumulatedConfig: ResolvedPrettierConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { isArray, isObject, type Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { isPackageExists } from \"local-pkg\";\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\nexport const combineConfigs = async (\n\tconfigArray: Array<Awaitable<ResolvedPrettierConfig | undefined>>\n): Promise<ResolvedPrettierConfig> => {\n\t// eslint-disable-next-line ts-eslint/await-thenable -- Ignore\n\tconst resolvedConfigArray = await Promise.all(configArray);\n\n\tlet accumulatedConfig: ResolvedPrettierConfig = {};\n\n\tfor (const config of resolvedConfigArray) {\n\t\tif (!config) continue;\n\n\t\taccumulatedConfig = mergeTwoConfigs(accumulatedConfig, config);\n\t}\n\n\treturn accumulatedConfig;\n};\n\nconst scopeUrl = fileURLToPath(new URL(\".\", import.meta.url));\nconst isCwdInScope = isPackageExists(\"@zayne-labs/prettier-config\");\n\nexport const isPackageInScope = (name: string): boolean => isPackageExists(name, { paths: [scopeUrl] });\n\n/**\n * @description\n * - Ensures that packages are installed in the current scope.\n * - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,\n * and the user is in the same scope as this package, then prompt the user to\n * install the packages.\n *\n * @param packages - The packages to ensure are installed.\n */\nexport const ensurePackages = async (packages: Array<string | undefined>): Promise<void> => {\n\tif (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;\n\n\tconst nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));\n\n\tif (nonExistingPackages.length === 0) return;\n\n\tconst clackPrompt = await import(\"@clack/prompts\");\n\n\tconst result = await clackPrompt.confirm({\n\t\tmessage: `${nonExistingPackages.length === 1 ? \"Package is\" : \"Packages are\"} required for this config: ${nonExistingPackages.join(\", \")}. Do you want to install them?`,\n\t});\n\n\tif (result) {\n\t\tconst antfuPkg = await import(\"@antfu/install-pkg\");\n\n\t\tawait antfuPkg.installPackage(nonExistingPackages as string[], { dev: true });\n\t}\n};\n"],"mappings":";;;;;;;;;AASA,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;;AAGR,MAAa,iBAAiB,OAC7B,gBACqC;CAErC,MAAM,sBAAsB,MAAM,QAAQ,IAAI,YAAY;CAE1D,IAAIC,oBAA4C,EAAE;AAElD,MAAK,MAAM,UAAU,qBAAqB;AACzC,MAAI,CAAC,OAAQ;AAEb,sBAAoB,gBAAgB,mBAAmB,OAAO;;AAG/D,QAAO;;AAGR,MAAM,WAAW,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC;AAC7D,MAAM,eAAe,gBAAgB,8BAA8B;AAEnE,MAAa,oBAAoB,SAA0B,gBAAgB,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;;;;;;;;;;AAWvG,MAAa,iBAAiB,OAAO,aAAuD;AAC3F,KAAI,QAAQ,IAAI,MAAM,CAAC,QAAQ,OAAO,SAAS,CAAC,aAAc;CAE9D,MAAM,sBAAsB,SAAS,QAAQ,QAAQ,OAAO,CAAC,iBAAiB,IAAI,CAAC;AAEnF,KAAI,oBAAoB,WAAW,EAAG;AAQtC,KAJe,OAFK,MAAM,OAAO,mBAEA,QAAQ,EACxC,SAAS,GAAG,oBAAoB,WAAW,IAAI,eAAe,eAAe,6BAA6B,oBAAoB,KAAK,KAAK,CAAC,iCACzI,CAAC,CAKD,QAFiB,MAAM,OAAO,uBAEf,eAAe,qBAAiC,EAAE,KAAK,MAAM,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { o as ResolvedPrettierConfig } from "./types-B17hDweL.js";
2
+ import { Awaitable } from "@zayne-labs/toolkit-type-helpers";
3
+
4
+ //#region src/utils.d.ts
5
+
6
+ /**
7
+ * @description Resolves a boolean or object option to an object.
8
+ * If the option is an object, it returns it as-is. Otherwise, returns an empty object.
9
+ */
10
+ declare const resolveOptions: <TObject>(option: boolean | TObject | undefined) => TObject;
11
+ /**
12
+ * @description Merges two Prettier configurations.
13
+ * Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.
14
+ */
15
+ declare const mergeTwoConfigs: (formerConfig: ResolvedPrettierConfig, latterConfig: ResolvedPrettierConfig) => ResolvedPrettierConfig;
16
+ declare const combineConfigs: (configArray: Array<Awaitable<ResolvedPrettierConfig | undefined>>) => Promise<ResolvedPrettierConfig>;
17
+ declare const isPackageInScope: (name: string) => boolean;
18
+ /**
19
+ * @description
20
+ * - Ensures that packages are installed in the current scope.
21
+ * - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,
22
+ * and the user is in the same scope as this package, then prompt the user to
23
+ * install the packages.
24
+ *
25
+ * @param packages - The packages to ensure are installed.
26
+ */
27
+ declare const ensurePackages: (packages: Array<string | undefined>) => Promise<void>;
28
+ //#endregion
29
+ export { combineConfigs, ensurePackages, isPackageInScope, mergeTwoConfigs, resolveOptions };
30
+ //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js ADDED
@@ -0,0 +1,3 @@
1
+ import { a as resolveOptions, i as mergeTwoConfigs, n as ensurePackages, r as isPackageInScope, t as combineConfigs } from "./utils-CEqE7-_1.js";
2
+
3
+ export { combineConfigs, ensurePackages, isPackageInScope, mergeTwoConfigs, resolveOptions };
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.7",
4
+ "version": "0.11.9",
5
5
  "description": "Zayne Labs' Prettier config",
6
6
  "author": "Ryan Zayne",
7
7
  "license": "MIT",
@@ -20,7 +20,9 @@
20
20
  ],
21
21
  "sideEffects": false,
22
22
  "exports": {
23
- ".": "./dist/index.js"
23
+ ".": "./dist/index.js",
24
+ "./utils": "./dist/utils.js",
25
+ "./constants/*": "./dist/constants/*.js"
24
26
  },
25
27
  "files": [
26
28
  "dist"
@@ -28,19 +30,47 @@
28
30
  "engines": {
29
31
  "node": ">=18.x"
30
32
  },
33
+ "peerDependencies": {
34
+ "prettier": "3.x.x",
35
+ "prettier-plugin-astro": "0.x.x",
36
+ "prettier-plugin-classnames": "0.x.x",
37
+ "prettier-plugin-merge": "0.x.x",
38
+ "prettier-plugin-tailwindcss": "0.x.x"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "prettier-plugin-astro": {
42
+ "optional": true
43
+ },
44
+ "prettier-plugin-classnames": {
45
+ "optional": true
46
+ },
47
+ "prettier-plugin-merge": {
48
+ "optional": true
49
+ },
50
+ "prettier-plugin-tailwindcss": {
51
+ "optional": true
52
+ }
53
+ },
31
54
  "dependencies": {
32
- "@zayne-labs/toolkit-type-helpers": "^0.12.17"
55
+ "@antfu/install-pkg": "1.1.0",
56
+ "@clack/prompts": "0.11.0",
57
+ "@ianvs/prettier-plugin-sort-imports": "4.x.x",
58
+ "@zayne-labs/toolkit-type-helpers": "0.12.17",
59
+ "local-pkg": "1.1.2"
33
60
  },
34
61
  "devDependencies": {
35
- "@arethetypeswrong/cli": "^0.18.2",
36
- "@changesets/cli": "^2.29.8",
37
- "@total-typescript/ts-reset": "^0.6.1",
38
- "concurrently": "^9.2.1",
39
- "cross-env": "^10.1.0",
40
- "publint": "^0.3.16",
41
- "tsdown": "^0.18.2",
62
+ "@total-typescript/ts-reset": "0.6.1",
63
+ "concurrently": "9.2.1",
64
+ "cross-env": "10.1.0",
65
+ "prettier": "3.7.4",
66
+ "prettier-plugin-astro": "0.14.1",
67
+ "prettier-plugin-classnames": "0.8.6",
68
+ "prettier-plugin-merge": "0.8.0",
69
+ "prettier-plugin-tailwindcss": "0.7.2",
70
+ "publint": "0.3.16",
71
+ "tsdown": "0.18.2",
42
72
  "typescript": "5.9.3",
43
- "@zayne-labs/tsconfig": "0.11.7"
73
+ "@zayne-labs/tsconfig": "0.11.9"
44
74
  },
45
75
  "publishConfig": {
46
76
  "access": "public",