js-style-kit 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/chunk-3H3TV7WG.js +21 -0
- package/dist/chunk-3H3TV7WG.js.map +1 -0
- package/dist/chunk-7D4SUZUM.js +38 -0
- package/dist/chunk-7D4SUZUM.js.map +1 -0
- package/dist/chunk-AL3W54BT.js +137 -0
- package/dist/chunk-AL3W54BT.js.map +1 -0
- package/dist/chunk-EQOUQWIX.js +45 -0
- package/dist/chunk-EQOUQWIX.js.map +1 -0
- package/dist/chunk-ETHEVVRU.js +1 -0
- package/dist/chunk-ETHEVVRU.js.map +1 -0
- package/dist/chunk-GE5ZPFK5.js +32 -0
- package/dist/chunk-GE5ZPFK5.js.map +1 -0
- package/dist/chunk-GZC424B7.js +36 -0
- package/dist/chunk-GZC424B7.js.map +1 -0
- package/dist/chunk-IOVQNUC6.js +21 -0
- package/dist/chunk-IOVQNUC6.js.map +1 -0
- package/dist/chunk-JY5TAY3J.js +428 -0
- package/dist/chunk-JY5TAY3J.js.map +1 -0
- package/dist/chunk-Q3UZX7NT.js +14 -0
- package/dist/chunk-Q3UZX7NT.js.map +1 -0
- package/dist/chunk-SVENELEJ.js +17576 -0
- package/dist/chunk-SVENELEJ.js.map +1 -0
- package/dist/chunk-TQWE6NWW.js +133 -0
- package/dist/chunk-TQWE6NWW.js.map +1 -0
- package/dist/chunk-UTXH73LC.js +42 -0
- package/dist/chunk-UTXH73LC.js.map +1 -0
- package/dist/chunk-W56QT6S7.js +14 -0
- package/dist/chunk-W56QT6S7.js.map +1 -0
- package/dist/chunk-YS5XHQB5.js +23 -0
- package/dist/chunk-YS5XHQB5.js.map +1 -0
- package/dist/eslint/constants.d.ts +10 -0
- package/dist/eslint/constants.js +8 -0
- package/dist/eslint/constants.js.map +1 -0
- package/dist/eslint/ignores.d.ts +5 -0
- package/dist/eslint/ignores.js +9 -0
- package/dist/eslint/ignores.js.map +1 -0
- package/dist/eslint/index.d.ts +25 -0
- package/dist/eslint/index.js +18 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/index.test.d.ts +2 -0
- package/dist/eslint/index.test.js +60 -0
- package/dist/eslint/index.test.js.map +1 -0
- package/dist/eslint/javascript/config.d.ts +6 -0
- package/dist/eslint/javascript/config.js +10 -0
- package/dist/eslint/javascript/config.js.map +1 -0
- package/dist/eslint/javascript/rules.d.ts +13 -0
- package/dist/eslint/javascript/rules.js +8 -0
- package/dist/eslint/javascript/rules.js.map +1 -0
- package/dist/eslint/perfectionist/config.d.ts +5 -0
- package/dist/eslint/perfectionist/config.js +10 -0
- package/dist/eslint/perfectionist/config.js.map +1 -0
- package/dist/eslint/perfectionist/rules.d.ts +10 -0
- package/dist/eslint/perfectionist/rules.js +8 -0
- package/dist/eslint/perfectionist/rules.js.map +1 -0
- package/dist/eslint/react/config.d.ts +6 -0
- package/dist/eslint/react/config.js +10 -0
- package/dist/eslint/react/config.js.map +1 -0
- package/dist/eslint/react/rules.d.ts +16 -0
- package/dist/eslint/react/rules.js +8 -0
- package/dist/eslint/react/rules.js.map +1 -0
- package/dist/eslint/typescript/config.d.ts +5 -0
- package/dist/eslint/typescript/config.js +10 -0
- package/dist/eslint/typescript/config.js.map +1 -0
- package/dist/eslint/typescript/rules.d.ts +5 -0
- package/dist/eslint/typescript/rules.js +8 -0
- package/dist/eslint/typescript/rules.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/magic-string.es-UEL4LDHN.js +1300 -0
- package/dist/magic-string.es-UEL4LDHN.js.map +1 -0
- package/dist/prettier/index.d.ts +27 -0
- package/dist/prettier/index.js +8 -0
- package/dist/prettier/index.js.map +1 -0
- package/dist/prettier/index.test.d.ts +2 -0
- package/dist/prettier/index.test.js +52 -0
- package/dist/prettier/index.test.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// src/eslint/react/rules.ts
|
|
2
|
+
var reactRules = (functionStyle, typescript) => {
|
|
3
|
+
const functionStyleMap = {
|
|
4
|
+
arrow: "arrow-function",
|
|
5
|
+
declaration: "function-declaration",
|
|
6
|
+
expression: "function-expression"
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
/**
|
|
10
|
+
* Disabled in favor of TypeScript for type checking, reducing build size
|
|
11
|
+
*/
|
|
12
|
+
...typescript ? {} : { "react/prop-types": "warn" },
|
|
13
|
+
/**
|
|
14
|
+
* Require an explicit type when using button elements.
|
|
15
|
+
*
|
|
16
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
17
|
+
*/
|
|
18
|
+
"react/button-has-type": "warn",
|
|
19
|
+
"react/destructuring-assignment": ["warn", "always"],
|
|
20
|
+
"react/display-name": "warn",
|
|
21
|
+
/**
|
|
22
|
+
* Require consistent function type for function components.
|
|
23
|
+
*
|
|
24
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
|
|
25
|
+
*/
|
|
26
|
+
"react/function-component-definition": [
|
|
27
|
+
"warn",
|
|
28
|
+
{
|
|
29
|
+
namedComponents: functionStyleMap[functionStyle],
|
|
30
|
+
unnamedComponents: functionStyle === "arrow" ? "arrow-function" : "function-expression"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
/**
|
|
34
|
+
* Require destructuring and symmetric naming of `useState` hook value and setter variables.
|
|
35
|
+
*
|
|
36
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
37
|
+
*/
|
|
38
|
+
"react/hook-use-state": "warn",
|
|
39
|
+
/**
|
|
40
|
+
* Require consistent boolean attributes notation in JSX.
|
|
41
|
+
*
|
|
42
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
43
|
+
*/
|
|
44
|
+
"react/jsx-boolean-value": "warn",
|
|
45
|
+
/**
|
|
46
|
+
* Disallow unnecessary curly braces in JSX props and children.
|
|
47
|
+
*
|
|
48
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
49
|
+
*/
|
|
50
|
+
"react/jsx-curly-brace-presence": "warn",
|
|
51
|
+
/**
|
|
52
|
+
* Require using shorthand form for React fragments, unless required.
|
|
53
|
+
*
|
|
54
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
55
|
+
*/
|
|
56
|
+
"react/jsx-fragments": "warn",
|
|
57
|
+
"react/jsx-key": "warn",
|
|
58
|
+
"react/jsx-no-comment-textnodes": "warn",
|
|
59
|
+
"react/jsx-no-duplicate-props": "warn",
|
|
60
|
+
/**
|
|
61
|
+
* Prevent problematic leaked values from being rendered.
|
|
62
|
+
*
|
|
63
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
|
|
64
|
+
*/
|
|
65
|
+
"react/jsx-no-leaked-render": "warn",
|
|
66
|
+
/**
|
|
67
|
+
* Prevents usage of unsafe `target='_blank'`.
|
|
68
|
+
*
|
|
69
|
+
* This rule is a part of `react/recommended`, but we've modified it to
|
|
70
|
+
* allow referrer.
|
|
71
|
+
*
|
|
72
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
|
73
|
+
*/
|
|
74
|
+
"react/jsx-no-target-blank": [
|
|
75
|
+
"warn",
|
|
76
|
+
{
|
|
77
|
+
allowReferrer: true
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"react/jsx-no-undef": "warn",
|
|
81
|
+
/**
|
|
82
|
+
* Disallow empty React fragments.
|
|
83
|
+
*
|
|
84
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
85
|
+
*/
|
|
86
|
+
"react/jsx-no-useless-fragment": ["warn", { allowExpressions: true }],
|
|
87
|
+
/**
|
|
88
|
+
* Require the use of PascalCase for user-defined JSX components.
|
|
89
|
+
*
|
|
90
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
91
|
+
*/
|
|
92
|
+
"react/jsx-pascal-case": "warn",
|
|
93
|
+
"react/jsx-uses-react": "warn",
|
|
94
|
+
"react/jsx-uses-vars": "warn",
|
|
95
|
+
/**
|
|
96
|
+
* Disallow usage of Array index in keys.
|
|
97
|
+
*
|
|
98
|
+
* � Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
99
|
+
*/
|
|
100
|
+
"react/no-array-index-key": "warn",
|
|
101
|
+
"react/no-children-prop": "warn",
|
|
102
|
+
"react/no-danger-with-children": "warn",
|
|
103
|
+
"react/no-deprecated": "warn",
|
|
104
|
+
"react/no-direct-mutation-state": "warn",
|
|
105
|
+
"react/no-find-dom-node": "warn",
|
|
106
|
+
"react/no-is-mounted": "warn",
|
|
107
|
+
"react/no-render-return-value": "warn",
|
|
108
|
+
"react/no-string-refs": "warn",
|
|
109
|
+
"react/no-unescaped-entities": "warn",
|
|
110
|
+
"react/no-unknown-property": "warn",
|
|
111
|
+
"react/no-unsafe": "warn",
|
|
112
|
+
/**
|
|
113
|
+
* Disallow creating unstable components inside components.
|
|
114
|
+
*
|
|
115
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
116
|
+
*/
|
|
117
|
+
"react/no-unstable-nested-components": "warn",
|
|
118
|
+
"react/prop-types": "warn",
|
|
119
|
+
"react/react-in-jsx-scope": "warn",
|
|
120
|
+
"react/require-render-return": "warn",
|
|
121
|
+
/**
|
|
122
|
+
* Disallow closing tags for components without children.
|
|
123
|
+
*
|
|
124
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
125
|
+
*/
|
|
126
|
+
"react/self-closing-comp": "warn"
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
reactRules
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=chunk-TQWE6NWW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eslint/react/rules.ts"],"sourcesContent":["import type { EslintRuleConfig, FunctionStyle } from \"../../types.js\";\n\ntype ReactFunctionDefinitions =\n | \"arrow-function\"\n | \"function-declaration\"\n | \"function-expression\";\n\ntype ReactRules = Record<`react/${string}`, EslintRuleConfig> & {\n \"react/destructuring-assignment\"?: EslintRuleConfig<\n \"always\" | \"never\",\n {\n destructureInSignature?: \"always\" | \"ignore\";\n ignoreClassFields?: boolean;\n }\n >;\n \"react/function-component-definition\"?: EslintRuleConfig<{\n namedComponents?: ReactFunctionDefinitions | ReactFunctionDefinitions[];\n unnamedComponents?:\n | \"arrow-function\"\n | \"function-expression\"\n | (\"arrow-function\" | \"function-expression\")[];\n }>;\n};\n\nexport const reactRules = (\n functionStyle: FunctionStyle,\n typescript: boolean,\n): ReactRules => {\n const functionStyleMap: Record<FunctionStyle, ReactFunctionDefinitions> = {\n arrow: \"arrow-function\",\n declaration: \"function-declaration\",\n expression: \"function-expression\",\n };\n\n return {\n /**\n * Disabled in favor of TypeScript for type checking, reducing build size\n */\n ...(typescript ? {} : { \"react/prop-types\": \"warn\" }),\n /**\n * Require an explicit type when using button elements.\n *\n * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md\n */\n \"react/button-has-type\": \"warn\",\n \"react/destructuring-assignment\": [\"warn\", \"always\"],\n \"react/display-name\": \"warn\",\n /**\n * Require consistent function type for function components.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md\n */\n \"react/function-component-definition\": [\n \"warn\",\n {\n namedComponents: functionStyleMap[functionStyle],\n unnamedComponents:\n functionStyle === \"arrow\" ? \"arrow-function\" : \"function-expression\",\n },\n ],\n /**\n * Require destructuring and symmetric naming of `useState` hook value and setter variables.\n *\n * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md\n */\n \"react/hook-use-state\": \"warn\",\n /**\n * Require consistent boolean attributes notation in JSX.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md\n */\n \"react/jsx-boolean-value\": \"warn\",\n /**\n * Disallow unnecessary curly braces in JSX props and children.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md\n */\n \"react/jsx-curly-brace-presence\": \"warn\",\n /**\n * Require using shorthand form for React fragments, unless required.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md\n */\n \"react/jsx-fragments\": \"warn\",\n \"react/jsx-key\": \"warn\",\n \"react/jsx-no-comment-textnodes\": \"warn\",\n \"react/jsx-no-duplicate-props\": \"warn\",\n /**\n * Prevent problematic leaked values from being rendered.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md\n */\n \"react/jsx-no-leaked-render\": \"warn\",\n /**\n * Prevents usage of unsafe `target='_blank'`.\n *\n * This rule is a part of `react/recommended`, but we've modified it to\n * allow referrer.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md\n */\n \"react/jsx-no-target-blank\": [\n \"warn\",\n {\n allowReferrer: true,\n },\n ],\n \"react/jsx-no-undef\": \"warn\",\n /**\n * Disallow empty React fragments.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md\n */\n \"react/jsx-no-useless-fragment\": [\"warn\", { allowExpressions: true }],\n /**\n * Require the use of PascalCase for user-defined JSX components.\n *\n * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md\n */\n \"react/jsx-pascal-case\": \"warn\",\n \"react/jsx-uses-react\": \"warn\",\n \"react/jsx-uses-vars\": \"warn\",\n /**\n * Disallow usage of Array index in keys.\n *\n * � Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md\n */\n \"react/no-array-index-key\": \"warn\",\n \"react/no-children-prop\": \"warn\",\n \"react/no-danger-with-children\": \"warn\",\n \"react/no-deprecated\": \"warn\",\n \"react/no-direct-mutation-state\": \"warn\",\n \"react/no-find-dom-node\": \"warn\",\n \"react/no-is-mounted\": \"warn\",\n \"react/no-render-return-value\": \"warn\",\n \"react/no-string-refs\": \"warn\",\n \"react/no-unescaped-entities\": \"warn\",\n \"react/no-unknown-property\": \"warn\",\n \"react/no-unsafe\": \"warn\",\n /**\n * Disallow creating unstable components inside components.\n *\n * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md\n */\n \"react/no-unstable-nested-components\": \"warn\",\n \"react/prop-types\": \"warn\",\n \"react/react-in-jsx-scope\": \"warn\",\n \"react/require-render-return\": \"warn\",\n /**\n * Disallow closing tags for components without children.\n *\n * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md\n */\n \"react/self-closing-comp\": \"warn\",\n };\n};\n"],"mappings":";AAwBO,IAAM,aAAa,CACxB,eACA,eACe;AACf,QAAM,mBAAoE;AAAA,IACxE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A0B;AAAA,IAC1B,uBAAuB;AAAA,IACvB,gCAAgC;AAAA,IAChC,wBAAwB;AAAA,IACxB,+BAA+B;AAAA,IAC/B,6BAA6B;AAAA,IAC7B,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMnB,uCAAuC;AAAA,IACvC,oBAAoB;AAAA,IACpB,4BAA4B;AAAA,IAC5B,+BAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAM/B,2BAA2B;AAAA,EAC7B;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/prettier/index.ts
|
|
2
|
+
var prettierConfig = (options = {}) => {
|
|
3
|
+
const {
|
|
4
|
+
jsonSortPlugin = true,
|
|
5
|
+
packageJsonPlugin = true,
|
|
6
|
+
tailwindPlugin = false,
|
|
7
|
+
...rest
|
|
8
|
+
} = options;
|
|
9
|
+
const plugins = [];
|
|
10
|
+
const config = {
|
|
11
|
+
experimentalTernaries: true,
|
|
12
|
+
...rest
|
|
13
|
+
};
|
|
14
|
+
if (jsonSortPlugin) {
|
|
15
|
+
plugins.push("prettier-plugin-sort-json");
|
|
16
|
+
config.jsonRecursiveSort = true;
|
|
17
|
+
}
|
|
18
|
+
if (packageJsonPlugin) {
|
|
19
|
+
plugins.push("prettier-plugin-packagejson");
|
|
20
|
+
}
|
|
21
|
+
if (tailwindPlugin) {
|
|
22
|
+
plugins.push("prettier-plugin-tailwindcss");
|
|
23
|
+
const defaultTailwindFunctions = ["clsx", "cva", "cn"];
|
|
24
|
+
if (Array.isArray(tailwindPlugin)) {
|
|
25
|
+
config.tailwindFunctions = [
|
|
26
|
+
...defaultTailwindFunctions,
|
|
27
|
+
...tailwindPlugin
|
|
28
|
+
];
|
|
29
|
+
} else if (typeof tailwindPlugin === "object") {
|
|
30
|
+
Object.assign(config, tailwindPlugin);
|
|
31
|
+
} else {
|
|
32
|
+
config.tailwindFunctions = defaultTailwindFunctions;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
config.plugins = plugins;
|
|
36
|
+
return config;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
prettierConfig
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=chunk-UTXH73LC.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\ninterface PrettierConfigOptions extends PrettierConfig {\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 * @param options - Configuration options for Prettier\n * @param options.tailwind Tailwind CSS formatting support\n * @param options.jsonSort JSON sorting support\n * @param options.packageJson Package.json sorting support\n * @returns Prettier configuration object with:\n * - Default Prettier configuration\n * - Experimental ternaries enabled\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 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 (jsonSortPlugin) {\n plugins.push(\"prettier-plugin-sort-json\");\n config.jsonRecursiveSort = true;\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 (Array.isArray(tailwindPlugin)) {\n config.tailwindFunctions = [\n ...defaultTailwindFunctions,\n ...tailwindPlugin,\n ];\n } else if (typeof tailwindPlugin === \"object\") {\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":";AA4BO,IAAM,iBAAiB,CAC5B,UAAiC,CAAC,MACJ;AAC9B,QAAM;AAAA,IACJ,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;AACxC,WAAO,oBAAoB;AAAA,EAC7B;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,MAAM,QAAQ,cAAc,GAAG;AACjC,aAAO,oBAAoB;AAAA,QACzB,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,IACF,WAAW,OAAO,mBAAmB,UAAU;AAC7C,aAAO,OAAO,QAAQ,cAAc;AAAA,IACtC,OAAO;AACL,aAAO,oBAAoB;AAAA,IAC7B;AAAA,EACF;AAGA,SAAO,UAAU;AAEjB,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/eslint/constants.ts
|
|
2
|
+
var configNames = {
|
|
3
|
+
base: "base-config",
|
|
4
|
+
disableTypeChecked: "typescript-eslint/disable-type-checked",
|
|
5
|
+
ignores: "ignores-config",
|
|
6
|
+
perfectionist: "perfectionist-config",
|
|
7
|
+
react: "react-config",
|
|
8
|
+
typescript: "tseslint-config"
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
configNames
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-W56QT6S7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eslint/constants.ts"],"sourcesContent":["export const configNames = {\n base: \"base-config\",\n disableTypeChecked: \"typescript-eslint/disable-type-checked\",\n ignores: \"ignores-config\",\n perfectionist: \"perfectionist-config\",\n react: \"react-config\",\n typescript: \"tseslint-config\",\n} as const;\n"],"mappings":";AAAO,IAAM,cAAc;AAAA,EACzB,MAAM;AAAA,EACN,oBAAoB;AAAA,EACpB,SAAS;AAAA,EACT,eAAe;AAAA,EACf,OAAO;AAAA,EACP,YAAY;AACd;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
reactRules
|
|
3
|
+
} from "./chunk-TQWE6NWW.js";
|
|
4
|
+
import {
|
|
5
|
+
configNames
|
|
6
|
+
} from "./chunk-W56QT6S7.js";
|
|
7
|
+
|
|
8
|
+
// src/eslint/react/config.ts
|
|
9
|
+
import react from "eslint-plugin-react";
|
|
10
|
+
var reactEslintConfig = (functionStyle, typescript) => {
|
|
11
|
+
return {
|
|
12
|
+
name: configNames.react,
|
|
13
|
+
plugins: {
|
|
14
|
+
react
|
|
15
|
+
},
|
|
16
|
+
rules: reactRules(functionStyle, typescript)
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
reactEslintConfig
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-YS5XHQB5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eslint/react/config.ts"],"sourcesContent":["import type { Linter } from \"eslint\";\n\nimport react from \"eslint-plugin-react\";\n\nimport type { FunctionStyle } from \"../../types.js\";\n\nimport { configNames } from \"../constants.js\";\nimport { reactRules } from \"./rules.js\";\n\nexport const reactEslintConfig = (\n functionStyle: FunctionStyle,\n typescript: boolean,\n): Linter.Config => {\n return {\n name: configNames.react,\n plugins: {\n react,\n },\n rules: reactRules(functionStyle, typescript),\n };\n};\n"],"mappings":";;;;;;;;AAEA,OAAO,WAAW;AAOX,IAAM,oBAAoB,CAC/B,eACA,eACkB;AAClB,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,SAAS;AAAA,MACP;AAAA,IACF;AAAA,IACA,OAAO,WAAW,eAAe,UAAU;AAAA,EAC7C;AACF;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const configNames: {
|
|
2
|
+
readonly base: "base-config";
|
|
3
|
+
readonly disableTypeChecked: "typescript-eslint/disable-type-checked";
|
|
4
|
+
readonly ignores: "ignores-config";
|
|
5
|
+
readonly perfectionist: "perfectionist-config";
|
|
6
|
+
readonly react: "react-config";
|
|
7
|
+
readonly typescript: "tseslint-config";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { configNames };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
import { FunctionStyle } from '../types.js';
|
|
3
|
+
|
|
4
|
+
interface EslintConfigOptions {
|
|
5
|
+
functionStyle?: FunctionStyle;
|
|
6
|
+
ignores?: string[];
|
|
7
|
+
import?: boolean;
|
|
8
|
+
react?: boolean;
|
|
9
|
+
sorting?: boolean;
|
|
10
|
+
typescript?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* This function configures your ESLint config based on inputs. It accepts a configuration object with the following properties:
|
|
14
|
+
*
|
|
15
|
+
* @param options
|
|
16
|
+
* @param options.functionStyle - The function style to use. Defaults to "arrow".
|
|
17
|
+
* @param options.ignores - An array of paths to ignore. Already excludes `node_modules` and `dist`.
|
|
18
|
+
* @param options.react - Whether to include React rules. Defaults to false.
|
|
19
|
+
* @param options.sorting - Whether to include sorting rules from Perfectionist. Defaults to true.
|
|
20
|
+
* @param options.typescript - Whether to include TypeScript rules. Defaults to true.
|
|
21
|
+
* @returns The ESLint configuration array.
|
|
22
|
+
*/
|
|
23
|
+
declare const eslintConfig: (options?: EslintConfigOptions) => Linter.Config[];
|
|
24
|
+
|
|
25
|
+
export { type EslintConfigOptions, eslintConfig };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
eslintConfig
|
|
3
|
+
} from "../chunk-EQOUQWIX.js";
|
|
4
|
+
import "../chunk-3H3TV7WG.js";
|
|
5
|
+
import "../chunk-JY5TAY3J.js";
|
|
6
|
+
import "../chunk-YS5XHQB5.js";
|
|
7
|
+
import "../chunk-TQWE6NWW.js";
|
|
8
|
+
import "../chunk-IOVQNUC6.js";
|
|
9
|
+
import "../chunk-GE5ZPFK5.js";
|
|
10
|
+
import "../chunk-GZC424B7.js";
|
|
11
|
+
import "../chunk-AL3W54BT.js";
|
|
12
|
+
import "../chunk-Q3UZX7NT.js";
|
|
13
|
+
import "../chunk-W56QT6S7.js";
|
|
14
|
+
import "../chunk-7D4SUZUM.js";
|
|
15
|
+
export {
|
|
16
|
+
eslintConfig
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
globalExpect,
|
|
4
|
+
it
|
|
5
|
+
} from "../chunk-SVENELEJ.js";
|
|
6
|
+
import {
|
|
7
|
+
eslintConfig
|
|
8
|
+
} from "../chunk-EQOUQWIX.js";
|
|
9
|
+
import "../chunk-3H3TV7WG.js";
|
|
10
|
+
import "../chunk-JY5TAY3J.js";
|
|
11
|
+
import "../chunk-YS5XHQB5.js";
|
|
12
|
+
import "../chunk-TQWE6NWW.js";
|
|
13
|
+
import "../chunk-IOVQNUC6.js";
|
|
14
|
+
import "../chunk-GE5ZPFK5.js";
|
|
15
|
+
import "../chunk-GZC424B7.js";
|
|
16
|
+
import "../chunk-AL3W54BT.js";
|
|
17
|
+
import "../chunk-Q3UZX7NT.js";
|
|
18
|
+
import {
|
|
19
|
+
configNames
|
|
20
|
+
} from "../chunk-W56QT6S7.js";
|
|
21
|
+
import "../chunk-7D4SUZUM.js";
|
|
22
|
+
|
|
23
|
+
// src/eslint/index.test.ts
|
|
24
|
+
describe("eslintConfig", () => {
|
|
25
|
+
it("returns default configuration", () => {
|
|
26
|
+
const config = eslintConfig();
|
|
27
|
+
const names = config.map((c) => c.name);
|
|
28
|
+
const expectedConfigs = [
|
|
29
|
+
configNames.ignores,
|
|
30
|
+
configNames.base,
|
|
31
|
+
configNames.typescript,
|
|
32
|
+
configNames.perfectionist,
|
|
33
|
+
configNames.disableTypeChecked,
|
|
34
|
+
// the disable type checked config comes with an additional un-named config
|
|
35
|
+
void 0
|
|
36
|
+
];
|
|
37
|
+
globalExpect(config).toBeInstanceOf(Array);
|
|
38
|
+
expectedConfigs.forEach((expectedName) => {
|
|
39
|
+
globalExpect(names).toContain(expectedName);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it("includes React config when enabled", () => {
|
|
43
|
+
const config = eslintConfig({ react: true });
|
|
44
|
+
globalExpect(config.some((c) => c.name === "react-config")).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
it("excludes TypeScript config when disabled", () => {
|
|
47
|
+
const config = eslintConfig({ typescript: false });
|
|
48
|
+
globalExpect(config.some((c) => c.name === "tseslint-config")).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
it("excludes sorting config when disabled", () => {
|
|
51
|
+
const config = eslintConfig({ sorting: false });
|
|
52
|
+
globalExpect(config.some((c) => c.name === "perfectionist-config")).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
it("applies custom ignores", () => {
|
|
55
|
+
const customIgnores = ["*.test.ts", "*.spec.ts"];
|
|
56
|
+
const config = eslintConfig({ ignores: customIgnores });
|
|
57
|
+
globalExpect(config[0]?.ignores).toEqual(globalExpect.arrayContaining(customIgnores));
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eslint/index.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\n\nimport { configNames } from \"./constants.js\";\nimport { eslintConfig } from \"./index.js\";\n\ndescribe(\"eslintConfig\", () => {\n it(\"returns default configuration\", () => {\n const config = eslintConfig();\n const names = config.map((c) => c.name);\n const expectedConfigs = [\n configNames.ignores,\n configNames.base,\n configNames.typescript,\n configNames.perfectionist,\n configNames.disableTypeChecked,\n // the disable type checked config comes with an additional un-named config\n undefined,\n ];\n\n expect(config).toBeInstanceOf(Array);\n expectedConfigs.forEach((expectedName) => {\n expect(names).toContain(expectedName);\n });\n });\n\n it(\"includes React config when enabled\", () => {\n const config = eslintConfig({ react: true });\n\n expect(config.some((c) => c.name === \"react-config\")).toBe(true);\n });\n\n it(\"excludes TypeScript config when disabled\", () => {\n const config = eslintConfig({ typescript: false });\n\n expect(config.some((c) => c.name === \"tseslint-config\")).toBe(false);\n });\n\n it(\"excludes sorting config when disabled\", () => {\n const config = eslintConfig({ sorting: false });\n\n expect(config.some((c) => c.name === \"perfectionist-config\")).toBe(false);\n });\n\n it(\"applies custom ignores\", () => {\n const customIgnores = [\"*.test.ts\", \"*.spec.ts\"];\n const config = eslintConfig({ ignores: customIgnores });\n\n expect(config[0]?.ignores).toEqual(expect.arrayContaining(customIgnores));\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,gBAAgB,MAAM;AAC7B,KAAG,iCAAiC,MAAM;AAC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+
import { FunctionStyle, EslintRuleConfig } from '../../types.js';
|
|
2
|
+
|
|
3
|
+
type BaseRules = Record<string, EslintRuleConfig> & {
|
|
4
|
+
"func-style"?: EslintRuleConfig<"declaration" | "expression", {
|
|
5
|
+
allowArrowFunctions?: boolean;
|
|
6
|
+
overrides?: {
|
|
7
|
+
namedExports?: "declaration" | "expression" | "ignore";
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
declare const baseEslintRules: (functionStyle: FunctionStyle) => BaseRules;
|
|
12
|
+
|
|
13
|
+
export { baseEslintRules };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EslintRuleConfig } from '../../types.js';
|
|
2
|
+
|
|
3
|
+
interface PerfectionistRuleOptions {
|
|
4
|
+
order: "asc" | "desc";
|
|
5
|
+
type: "alphabetical" | "custom" | "line-length" | "natural";
|
|
6
|
+
}
|
|
7
|
+
type PerfectionRules = Record<`perfectionist/${string}`, EslintRuleConfig<PerfectionistRuleOptions>>;
|
|
8
|
+
declare const perfectionistRules: PerfectionRules;
|
|
9
|
+
|
|
10
|
+
export { perfectionistRules };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FunctionStyle, EslintRuleConfig } from '../../types.js';
|
|
2
|
+
|
|
3
|
+
type ReactFunctionDefinitions = "arrow-function" | "function-declaration" | "function-expression";
|
|
4
|
+
type ReactRules = Record<`react/${string}`, EslintRuleConfig> & {
|
|
5
|
+
"react/destructuring-assignment"?: EslintRuleConfig<"always" | "never", {
|
|
6
|
+
destructureInSignature?: "always" | "ignore";
|
|
7
|
+
ignoreClassFields?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
"react/function-component-definition"?: EslintRuleConfig<{
|
|
10
|
+
namedComponents?: ReactFunctionDefinitions | ReactFunctionDefinitions[];
|
|
11
|
+
unnamedComponents?: "arrow-function" | "function-expression" | ("arrow-function" | "function-expression")[];
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
declare const reactRules: (functionStyle: FunctionStyle, typescript: boolean) => ReactRules;
|
|
15
|
+
|
|
16
|
+
export { reactRules };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { EslintConfigOptions, eslintConfig } from './eslint/index.js';
|
|
2
|
+
export { PrettierConfigWithPlugins, prettierConfig } from './prettier/index.js';
|
|
3
|
+
export { EslintRuleConfig, EslintSeverity, FunctionStyle } from './types.js';
|
|
4
|
+
import 'eslint';
|
|
5
|
+
import 'prettier';
|
|
6
|
+
import 'prettier-plugin-sort-json';
|
|
7
|
+
import 'prettier-plugin-tailwindcss';
|