js-style-kit 0.2.0 → 0.2.1
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/{chunk-C63QD4BT.js → chunk-E53SVIZM.js} +9 -8
- package/dist/chunk-E53SVIZM.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/prettier/index.d.ts +2 -2
- package/dist/prettier/index.js +1 -1
- package/dist/scripts/postinstall.js +58 -0
- package/dist/scripts/postinstall.js.map +1 -0
- package/package.json +3 -2
- package/dist/chunk-C63QD4BT.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
isObject,
|
|
3
|
+
isString
|
|
4
4
|
} from "./chunk-PSSB4TGO.js";
|
|
5
5
|
|
|
6
6
|
// src/prettier/index.ts
|
|
@@ -34,13 +34,14 @@ var prettierConfig = (options = {}) => {
|
|
|
34
34
|
if (tailwindPlugin) {
|
|
35
35
|
plugins.push("prettier-plugin-tailwindcss");
|
|
36
36
|
const defaultTailwindFunctions = ["clsx", "cva", "cn"];
|
|
37
|
-
if (
|
|
38
|
-
config.
|
|
39
|
-
|
|
40
|
-
...tailwindPlugin
|
|
41
|
-
];
|
|
37
|
+
if (isString(tailwindPlugin)) {
|
|
38
|
+
config.tailwindStylesheet = tailwindPlugin;
|
|
39
|
+
config.tailwindFunctions = defaultTailwindFunctions;
|
|
42
40
|
} else if (isObject(tailwindPlugin)) {
|
|
43
41
|
Object.assign(config, tailwindPlugin);
|
|
42
|
+
if (!tailwindPlugin.tailwindFunctions) {
|
|
43
|
+
config.tailwindFunctions = defaultTailwindFunctions;
|
|
44
|
+
}
|
|
44
45
|
} else {
|
|
45
46
|
config.tailwindFunctions = defaultTailwindFunctions;
|
|
46
47
|
}
|
|
@@ -52,4 +53,4 @@ var prettierConfig = (options = {}) => {
|
|
|
52
53
|
export {
|
|
53
54
|
prettierConfig
|
|
54
55
|
};
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-E53SVIZM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/prettier/index.ts"],"sourcesContent":["import type { Config as PrettierConfig } from \"prettier\";\nimport type { SortJsonOptions as SortJsonPluginOptions } from \"prettier-plugin-sort-json\";\nimport type { PluginOptions as TailwindPluginOptions } from \"prettier-plugin-tailwindcss\";\n\nimport { isObject, isString } from \"../utils/is-type.js\";\n\nexport interface PrettierConfigOptions extends PrettierConfig {\n cssOrderPlugin?: boolean;\n jsonSortPlugin?: boolean | SortJsonPluginOptions;\n packageJsonPlugin?: boolean;\n tailwindPlugin?: boolean | string | TailwindPluginOptions;\n}\n\nexport interface PrettierConfigWithPlugins\n extends PrettierConfig,\n SortJsonPluginOptions,\n TailwindPluginOptions {}\n\n/**\n * Creates a Prettier configuration object with optional Tailwind support\n *\n * @param options - Configuration options for Prettier\n * @param options.cssOrderPlugin CSS order sorting support\n * @param options.jsonSortPlugin JSON sorting support\n * @param options.packageJsonPlugin Package.json sorting support\n * @param options.tailwindPlugin Tailwind CSS formatting support\n * @returns Prettier configuration object with:\n * - Default Prettier configuration\n * - Experimental ternaries enabled\n * - CSS order plugin\n * - JSON sorting plugin\n * - Package.json sorting plugin\n * - Optional Tailwind plugin and functions\n */\nexport const prettierConfig = (\n options: PrettierConfigOptions = {},\n): PrettierConfigWithPlugins => {\n const {\n cssOrderPlugin = true,\n jsonSortPlugin = true,\n packageJsonPlugin = true,\n tailwindPlugin = false,\n ...rest\n } = options;\n\n const plugins: string[] = [];\n const config: PrettierConfigWithPlugins = {\n experimentalTernaries: true,\n ...rest,\n };\n\n if (cssOrderPlugin) {\n plugins.push(\"prettier-plugin-css-order\");\n }\n\n if (jsonSortPlugin) {\n plugins.push(\"prettier-plugin-sort-json\");\n\n if (isObject(jsonSortPlugin)) {\n Object.assign(config, jsonSortPlugin);\n } else {\n config.jsonRecursiveSort = true;\n }\n }\n\n if (packageJsonPlugin) {\n plugins.push(\"prettier-plugin-packagejson\");\n }\n\n if (tailwindPlugin) {\n plugins.push(\"prettier-plugin-tailwindcss\");\n const defaultTailwindFunctions = [\"clsx\", \"cva\", \"cn\"];\n\n if (isString(tailwindPlugin)) {\n // then it's the path to the stylesheet\n config.tailwindStylesheet = tailwindPlugin;\n config.tailwindFunctions = defaultTailwindFunctions;\n } else if (isObject(tailwindPlugin)) {\n Object.assign(config, tailwindPlugin);\n\n // Ensure defaultTailwindFunctions is applied if tailwindFunctions wasn't specified\n if (!tailwindPlugin.tailwindFunctions) {\n config.tailwindFunctions = defaultTailwindFunctions;\n }\n } else {\n config.tailwindFunctions = defaultTailwindFunctions;\n }\n }\n\n // Set plugins after all configurations are done\n config.plugins = plugins;\n\n return config;\n};\n"],"mappings":";;;;;;AAkCO,IAAM,iBAAiB,CAC5B,UAAiC,CAAC,MACJ;AAC9B,QAAM;AAAA,IACJ,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,UAAoB,CAAC;AAC3B,QAAM,SAAoC;AAAA,IACxC,uBAAuB;AAAA,IACvB,GAAG;AAAA,EACL;AAEA,MAAI,gBAAgB;AAClB,YAAQ,KAAK,2BAA2B;AAAA,EAC1C;AAEA,MAAI,gBAAgB;AAClB,YAAQ,KAAK,2BAA2B;AAExC,QAAI,SAAS,cAAc,GAAG;AAC5B,aAAO,OAAO,QAAQ,cAAc;AAAA,IACtC,OAAO;AACL,aAAO,oBAAoB;AAAA,IAC7B;AAAA,EACF;AAEA,MAAI,mBAAmB;AACrB,YAAQ,KAAK,6BAA6B;AAAA,EAC5C;AAEA,MAAI,gBAAgB;AAClB,YAAQ,KAAK,6BAA6B;AAC1C,UAAM,2BAA2B,CAAC,QAAQ,OAAO,IAAI;AAErD,QAAI,SAAS,cAAc,GAAG;AAE5B,aAAO,qBAAqB;AAC5B,aAAO,oBAAoB;AAAA,IAC7B,WAAW,SAAS,cAAc,GAAG;AACnC,aAAO,OAAO,QAAQ,cAAc;AAGpC,UAAI,CAAC,eAAe,mBAAmB;AACrC,eAAO,oBAAoB;AAAA,MAC7B;AAAA,IACF,OAAO;AACL,aAAO,oBAAoB;AAAA,IAC7B;AAAA,EACF;AAGA,SAAO,UAAU;AAEjB,SAAO;AACT;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { EslintConfigOptions, eslintConfig } from './eslint/index.js';
|
|
2
2
|
export { EslintConfigObject, EslintRuleConfig, EslintSeverity, FunctionStyle } from './eslint/types.js';
|
|
3
|
-
export { PrettierConfigWithPlugins, prettierConfig } from './prettier/index.js';
|
|
3
|
+
export { PrettierConfigOptions, PrettierConfigWithPlugins, prettierConfig } from './prettier/index.js';
|
|
4
4
|
import 'eslint';
|
|
5
5
|
import './eslint/testing/config.js';
|
|
6
6
|
import './eslint/constants.js';
|
package/dist/index.js
CHANGED
package/dist/prettier/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ interface PrettierConfigOptions extends Config {
|
|
|
6
6
|
cssOrderPlugin?: boolean;
|
|
7
7
|
jsonSortPlugin?: boolean | SortJsonOptions;
|
|
8
8
|
packageJsonPlugin?: boolean;
|
|
9
|
-
tailwindPlugin?: boolean | string
|
|
9
|
+
tailwindPlugin?: boolean | string | PluginOptions;
|
|
10
10
|
}
|
|
11
11
|
interface PrettierConfigWithPlugins extends Config, SortJsonOptions, PluginOptions {
|
|
12
12
|
}
|
|
@@ -28,4 +28,4 @@ interface PrettierConfigWithPlugins extends Config, SortJsonOptions, PluginOptio
|
|
|
28
28
|
*/
|
|
29
29
|
declare const prettierConfig: (options?: PrettierConfigOptions) => PrettierConfigWithPlugins;
|
|
30
30
|
|
|
31
|
-
export { type PrettierConfigWithPlugins, prettierConfig };
|
|
31
|
+
export { type PrettierConfigOptions, type PrettierConfigWithPlugins, prettierConfig };
|
package/dist/prettier/index.js
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// scripts/postinstall.js
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
var patchPrettierPluginTailwindcss = () => {
|
|
5
|
+
try {
|
|
6
|
+
const pluginPath = path.join(
|
|
7
|
+
process.cwd(),
|
|
8
|
+
"node_modules/prettier-plugin-tailwindcss/dist/index.d.ts"
|
|
9
|
+
);
|
|
10
|
+
if (!fs.existsSync(pluginPath)) {
|
|
11
|
+
console.warn("prettier-plugin-tailwindcss not found, skipping patch");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const packageJsonPath = path.join(
|
|
15
|
+
process.cwd(),
|
|
16
|
+
"node_modules/prettier-plugin-tailwindcss/package.json"
|
|
17
|
+
);
|
|
18
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
19
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
20
|
+
console.info(
|
|
21
|
+
`Detected prettier-plugin-tailwindcss version: ${packageJson.version}`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
fs.writeFileSync(
|
|
25
|
+
`${pluginPath}.backup`,
|
|
26
|
+
fs.readFileSync(pluginPath, "utf8")
|
|
27
|
+
);
|
|
28
|
+
console.info("Created backup of original declaration file");
|
|
29
|
+
const content = fs.readFileSync(pluginPath, "utf8");
|
|
30
|
+
const declareBlock = `declare module 'prettier' {
|
|
31
|
+
interface RequiredOptions extends PluginOptions {
|
|
32
|
+
}
|
|
33
|
+
interface ParserOptions extends PluginOptions {
|
|
34
|
+
}
|
|
35
|
+
}`;
|
|
36
|
+
const patchedContent = content.replace(
|
|
37
|
+
declareBlock,
|
|
38
|
+
"// Removed unsafe declare module statement"
|
|
39
|
+
);
|
|
40
|
+
if (content !== patchedContent) {
|
|
41
|
+
fs.writeFileSync(pluginPath, patchedContent);
|
|
42
|
+
console.info(
|
|
43
|
+
"js-style-kit: Successfully patched prettier-plugin-tailwindcss declaration file"
|
|
44
|
+
);
|
|
45
|
+
} else {
|
|
46
|
+
console.info(
|
|
47
|
+
"No patching needed, declaration block not found or already patched"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(
|
|
52
|
+
"js-style-kit: Error patching prettier-plugin-tailwindcss:",
|
|
53
|
+
error
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
patchPrettierPluginTailwindcss();
|
|
58
|
+
//# sourceMappingURL=postinstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../scripts/postinstall.js"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n/**\n * Patch the declaration file of prettier-plugin-tailwindcss to remove the unsafe declare statement\n */\nconst patchPrettierPluginTailwindcss = () => {\n try {\n // Path to the declaration file with the unsafe declare statement\n const pluginPath = path.join(\n process.cwd(),\n \"node_modules/prettier-plugin-tailwindcss/dist/index.d.ts\",\n );\n\n if (!fs.existsSync(pluginPath)) {\n console.warn(\"prettier-plugin-tailwindcss not found, skipping patch\");\n return;\n }\n\n // Verify plugin version to ensure patch is applicable\n const packageJsonPath = path.join(\n process.cwd(),\n \"node_modules/prettier-plugin-tailwindcss/package.json\",\n );\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n console.info(\n `Detected prettier-plugin-tailwindcss version: ${packageJson.version}`,\n );\n }\n\n // Create backup of original file\n fs.writeFileSync(\n `${pluginPath}.backup`,\n fs.readFileSync(pluginPath, \"utf8\"),\n );\n console.info(\"Created backup of original declaration file\");\n\n // Read the file\n const content = fs.readFileSync(pluginPath, \"utf8\");\n\n // The exact declare statement to remove\n const declareBlock = `declare module 'prettier' {\n interface RequiredOptions extends PluginOptions {\n }\n interface ParserOptions extends PluginOptions {\n }\n}`;\n\n // Replace the declare block with a comment\n const patchedContent = content.replace(\n declareBlock,\n \"// Removed unsafe declare module statement\",\n );\n\n // Only write if content has changed\n if (content !== patchedContent) {\n // Write the patched file back\n fs.writeFileSync(pluginPath, patchedContent);\n console.info(\n \"js-style-kit: Successfully patched prettier-plugin-tailwindcss declaration file\",\n );\n } else {\n console.info(\n \"No patching needed, declaration block not found or already patched\",\n );\n }\n } catch (error) {\n console.error(\n \"js-style-kit: Error patching prettier-plugin-tailwindcss:\",\n error,\n );\n }\n};\n\n// Run the patch function\npatchPrettierPluginTailwindcss();\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AAKtB,IAAM,iCAAiC,MAAM;AAC3C,MAAI;AAEF,UAAM,aAAkB;AAAA,MACtB,QAAQ,IAAI;AAAA,MACZ;AAAA,IACF;AAEA,QAAI,CAAI,cAAW,UAAU,GAAG;AAC9B,cAAQ,KAAK,uDAAuD;AACpE;AAAA,IACF;AAGA,UAAM,kBAAuB;AAAA,MAC3B,QAAQ,IAAI;AAAA,MACZ;AAAA,IACF;AACA,QAAO,cAAW,eAAe,GAAG;AAClC,YAAM,cAAc,KAAK,MAAS,gBAAa,iBAAiB,MAAM,CAAC;AACvE,cAAQ;AAAA,QACN,iDAAiD,YAAY,OAAO;AAAA,MACtE;AAAA,IACF;AAGA,IAAG;AAAA,MACD,GAAG,UAAU;AAAA,MACV,gBAAa,YAAY,MAAM;AAAA,IACpC;AACA,YAAQ,KAAK,6CAA6C;AAG1D,UAAM,UAAa,gBAAa,YAAY,MAAM;AAGlD,UAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAQrB,UAAM,iBAAiB,QAAQ;AAAA,MAC7B;AAAA,MACA;AAAA,IACF;AAGA,QAAI,YAAY,gBAAgB;AAE9B,MAAG,iBAAc,YAAY,cAAc;AAC3C,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,YAAQ;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAGA,+BAA+B;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-style-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A zero configuration style guide for ESLint and Prettier",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"dev": "tsup --watch",
|
|
33
33
|
"format": "prettier --write . --ignore-path .prettierignore.ci",
|
|
34
34
|
"format:check": "prettier --check . --ignore-path .prettierignore.ci",
|
|
35
|
+
"postinstall": "node ./dist/scripts/postinstall.js",
|
|
35
36
|
"lint": "eslint .",
|
|
36
37
|
"lint:inspect": "eslint --inspect-config",
|
|
37
38
|
"test": "bun test",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"eslint": "^9.22.0",
|
|
42
43
|
"eslint-plugin-jest": "^28.11.0",
|
|
43
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
44
|
+
"eslint-plugin-jsdoc": "^50.6.8",
|
|
44
45
|
"eslint-plugin-perfectionist": "^4.10.1",
|
|
45
46
|
"eslint-plugin-prefer-arrow-functions": "^3.6.2",
|
|
46
47
|
"eslint-plugin-react": "^7.37.4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/prettier/index.ts"],"sourcesContent":["import type { Config as PrettierConfig } from \"prettier\";\nimport type { SortJsonOptions as SortJsonPluginOptions } from \"prettier-plugin-sort-json\";\nimport type { PluginOptions as TailwindPluginOptions } from \"prettier-plugin-tailwindcss\";\n\nimport { isArray, isObject } from \"../utils/is-type.js\";\n\ninterface PrettierConfigOptions extends PrettierConfig {\n cssOrderPlugin?: boolean;\n jsonSortPlugin?: boolean | SortJsonPluginOptions;\n packageJsonPlugin?: boolean;\n tailwindPlugin?: boolean | string[] | TailwindPluginOptions;\n}\n\nexport interface PrettierConfigWithPlugins\n extends PrettierConfig,\n SortJsonPluginOptions,\n TailwindPluginOptions {}\n\n/**\n * Creates a Prettier configuration object with optional Tailwind support\n *\n * @param options - Configuration options for Prettier\n * @param options.cssOrderPlugin CSS order sorting support\n * @param options.jsonSortPlugin JSON sorting support\n * @param options.packageJsonPlugin Package.json sorting support\n * @param options.tailwindPlugin Tailwind CSS formatting support\n * @returns Prettier configuration object with:\n * - Default Prettier configuration\n * - Experimental ternaries enabled\n * - CSS order plugin\n * - JSON sorting plugin\n * - Package.json sorting plugin\n * - Optional Tailwind plugin and functions\n */\nexport const prettierConfig = (\n options: PrettierConfigOptions = {},\n): PrettierConfigWithPlugins => {\n const {\n cssOrderPlugin = true,\n jsonSortPlugin = true,\n packageJsonPlugin = true,\n tailwindPlugin = false,\n ...rest\n } = options;\n\n const plugins: string[] = [];\n const config: PrettierConfigWithPlugins = {\n experimentalTernaries: true,\n ...rest,\n };\n\n if (cssOrderPlugin) {\n plugins.push(\"prettier-plugin-css-order\");\n }\n\n if (jsonSortPlugin) {\n plugins.push(\"prettier-plugin-sort-json\");\n\n if (isObject(jsonSortPlugin)) {\n Object.assign(config, jsonSortPlugin);\n } else {\n config.jsonRecursiveSort = true;\n }\n }\n\n if (packageJsonPlugin) {\n plugins.push(\"prettier-plugin-packagejson\");\n }\n\n if (tailwindPlugin) {\n plugins.push(\"prettier-plugin-tailwindcss\");\n const defaultTailwindFunctions = [\"clsx\", \"cva\", \"cn\"];\n\n if (isArray(tailwindPlugin)) {\n config.tailwindFunctions = [\n ...defaultTailwindFunctions,\n ...tailwindPlugin,\n ];\n } else if (isObject(tailwindPlugin)) {\n Object.assign(config, tailwindPlugin);\n } else {\n config.tailwindFunctions = defaultTailwindFunctions;\n }\n }\n\n // Set plugins after all configurations are done\n config.plugins = plugins;\n\n return config;\n};\n"],"mappings":";;;;;;AAkCO,IAAM,iBAAiB,CAC5B,UAAiC,CAAC,MACJ;AAC9B,QAAM;AAAA,IACJ,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,UAAoB,CAAC;AAC3B,QAAM,SAAoC;AAAA,IACxC,uBAAuB;AAAA,IACvB,GAAG;AAAA,EACL;AAEA,MAAI,gBAAgB;AAClB,YAAQ,KAAK,2BAA2B;AAAA,EAC1C;AAEA,MAAI,gBAAgB;AAClB,YAAQ,KAAK,2BAA2B;AAExC,QAAI,SAAS,cAAc,GAAG;AAC5B,aAAO,OAAO,QAAQ,cAAc;AAAA,IACtC,OAAO;AACL,aAAO,oBAAoB;AAAA,IAC7B;AAAA,EACF;AAEA,MAAI,mBAAmB;AACrB,YAAQ,KAAK,6BAA6B;AAAA,EAC5C;AAEA,MAAI,gBAAgB;AAClB,YAAQ,KAAK,6BAA6B;AAC1C,UAAM,2BAA2B,CAAC,QAAQ,OAAO,IAAI;AAErD,QAAI,QAAQ,cAAc,GAAG;AAC3B,aAAO,oBAAoB;AAAA,QACzB,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,IACF,WAAW,SAAS,cAAc,GAAG;AACnC,aAAO,OAAO,QAAQ,cAAc;AAAA,IACtC,OAAO;AACL,aAAO,oBAAoB;AAAA,IAC7B;AAAA,EACF;AAGA,SAAO,UAAU;AAEjB,SAAO;AACT;","names":[]}
|