uilint-eslint 0.2.9 → 0.2.10
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-IL6RYCMD.js → chunk-6EI7LWV5.js} +6 -2
- package/dist/chunk-6EI7LWV5.js.map +1 -0
- package/dist/index.d.ts +85 -57
- package/dist/index.js +628 -200
- package/dist/index.js.map +1 -1
- package/dist/rules/consistent-dark-mode.js +79 -3
- package/dist/rules/consistent-dark-mode.js.map +1 -1
- package/dist/rules/consistent-spacing.js +66 -3
- package/dist/rules/consistent-spacing.js.map +1 -1
- package/dist/rules/no-arbitrary-tailwind.js +50 -3
- package/dist/rules/no-arbitrary-tailwind.js.map +1 -1
- package/dist/rules/no-direct-store-import.js +79 -3
- package/dist/rules/no-direct-store-import.js.map +1 -1
- package/dist/rules/no-mixed-component-libraries.js +86 -3
- package/dist/rules/no-mixed-component-libraries.js.map +1 -1
- package/dist/rules/prefer-zustand-state-management.js +114 -3
- package/dist/rules/prefer-zustand-state-management.js.map +1 -1
- package/dist/rules/semantic-vision.js +78 -3
- package/dist/rules/semantic-vision.js.map +1 -1
- package/dist/rules/semantic.js +91 -3
- package/dist/rules/semantic.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +7 -1
- package/src/rule-registry.ts +51 -256
- package/src/rules/consistent-dark-mode.ts +79 -1
- package/src/rules/consistent-spacing.ts +66 -1
- package/src/rules/no-arbitrary-tailwind.ts +50 -1
- package/src/rules/no-direct-store-import.ts +79 -1
- package/src/rules/no-mixed-component-libraries.ts +86 -1
- package/src/rules/prefer-zustand-state-management.ts +114 -1
- package/src/rules/semantic-vision.ts +78 -1
- package/src/rules/semantic.ts +91 -1
- package/src/utils/create-rule.ts +77 -0
- package/dist/chunk-IL6RYCMD.js.map +0 -1
|
@@ -3,8 +3,12 @@ import { ESLintUtils } from "@typescript-eslint/utils";
|
|
|
3
3
|
var createRule = ESLintUtils.RuleCreator(
|
|
4
4
|
(name) => `https://github.com/peter-suggate/uilint/blob/main/packages/uilint-eslint/docs/rules/${name}.md`
|
|
5
5
|
);
|
|
6
|
+
function defineRuleMeta(meta) {
|
|
7
|
+
return meta;
|
|
8
|
+
}
|
|
6
9
|
|
|
7
10
|
export {
|
|
8
|
-
createRule
|
|
11
|
+
createRule,
|
|
12
|
+
defineRuleMeta
|
|
9
13
|
};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
//# sourceMappingURL=chunk-6EI7LWV5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/create-rule.ts"],"sourcesContent":["/**\n * Rule creation helper using @typescript-eslint/utils\n */\n\nimport { ESLintUtils } from \"@typescript-eslint/utils\";\n\nexport const createRule = ESLintUtils.RuleCreator(\n (name) =>\n `https://github.com/peter-suggate/uilint/blob/main/packages/uilint-eslint/docs/rules/${name}.md`\n);\n\n/**\n * Schema for prompting user to configure a rule option in the CLI\n */\nexport interface OptionFieldSchema {\n /** Field name in the options object */\n key: string;\n /** Display label for the prompt */\n label: string;\n /** Prompt type */\n type: \"text\" | \"number\" | \"boolean\" | \"select\" | \"multiselect\";\n /** Default value */\n defaultValue: unknown;\n /** Placeholder text (for text/number inputs) */\n placeholder?: string;\n /** Options for select/multiselect */\n options?: Array<{ value: string | number; label: string }>;\n /** Description/hint for the field */\n description?: string;\n}\n\n/**\n * Schema describing how to prompt for rule options during installation\n */\nexport interface RuleOptionSchema {\n /** Fields that can be configured for this rule */\n fields: OptionFieldSchema[];\n}\n\n/**\n * Colocated rule metadata - exported alongside each rule\n *\n * This structure keeps all rule metadata in the same file as the rule implementation,\n * making it easy to maintain and extend as new rules are added.\n */\nexport interface RuleMeta {\n /** Rule identifier (e.g., \"no-arbitrary-tailwind\") - must match filename */\n id: string;\n\n /** Display name for CLI (e.g., \"No Arbitrary Tailwind\") */\n name: string;\n\n /** Short description for CLI selection prompts (one line) */\n description: string;\n\n /** Default severity level */\n defaultSeverity: \"error\" | \"warn\" | \"off\";\n\n /** Category for grouping in CLI */\n category: \"static\" | \"semantic\";\n\n /** Whether this rule requires a styleguide file */\n requiresStyleguide?: boolean;\n\n /** Default options for the rule (passed as second element in ESLint config) */\n defaultOptions?: unknown[];\n\n /** Schema for prompting user to configure options during install */\n optionSchema?: RuleOptionSchema;\n\n /**\n * Detailed documentation in markdown format.\n * Should include:\n * - What the rule does\n * - Why it's useful\n * - Examples of incorrect and correct code\n * - Configuration options explained\n */\n docs: string;\n}\n\n/**\n * Helper to define rule metadata with type safety\n */\nexport function defineRuleMeta(meta: RuleMeta): RuleMeta {\n return meta;\n}\n"],"mappings":";AAIA,SAAS,mBAAmB;AAErB,IAAM,aAAa,YAAY;AAAA,EACpC,CAAC,SACC,uFAAuF,IAAI;AAC/F;AA2EO,SAAS,eAAe,MAA0B;AACvD,SAAO;AACT;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,72 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
9
9
|
declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
|
|
10
10
|
name: string;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Schema for prompting user to configure a rule option in the CLI
|
|
14
|
+
*/
|
|
15
|
+
interface OptionFieldSchema {
|
|
16
|
+
/** Field name in the options object */
|
|
17
|
+
key: string;
|
|
18
|
+
/** Display label for the prompt */
|
|
19
|
+
label: string;
|
|
20
|
+
/** Prompt type */
|
|
21
|
+
type: "text" | "number" | "boolean" | "select" | "multiselect";
|
|
22
|
+
/** Default value */
|
|
23
|
+
defaultValue: unknown;
|
|
24
|
+
/** Placeholder text (for text/number inputs) */
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
/** Options for select/multiselect */
|
|
27
|
+
options?: Array<{
|
|
28
|
+
value: string | number;
|
|
29
|
+
label: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** Description/hint for the field */
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Schema describing how to prompt for rule options during installation
|
|
36
|
+
*/
|
|
37
|
+
interface RuleOptionSchema {
|
|
38
|
+
/** Fields that can be configured for this rule */
|
|
39
|
+
fields: OptionFieldSchema[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Colocated rule metadata - exported alongside each rule
|
|
43
|
+
*
|
|
44
|
+
* This structure keeps all rule metadata in the same file as the rule implementation,
|
|
45
|
+
* making it easy to maintain and extend as new rules are added.
|
|
46
|
+
*/
|
|
47
|
+
interface RuleMeta {
|
|
48
|
+
/** Rule identifier (e.g., "no-arbitrary-tailwind") - must match filename */
|
|
49
|
+
id: string;
|
|
50
|
+
/** Display name for CLI (e.g., "No Arbitrary Tailwind") */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Short description for CLI selection prompts (one line) */
|
|
53
|
+
description: string;
|
|
54
|
+
/** Default severity level */
|
|
55
|
+
defaultSeverity: "error" | "warn" | "off";
|
|
56
|
+
/** Category for grouping in CLI */
|
|
57
|
+
category: "static" | "semantic";
|
|
58
|
+
/** Whether this rule requires a styleguide file */
|
|
59
|
+
requiresStyleguide?: boolean;
|
|
60
|
+
/** Default options for the rule (passed as second element in ESLint config) */
|
|
61
|
+
defaultOptions?: unknown[];
|
|
62
|
+
/** Schema for prompting user to configure options during install */
|
|
63
|
+
optionSchema?: RuleOptionSchema;
|
|
64
|
+
/**
|
|
65
|
+
* Detailed documentation in markdown format.
|
|
66
|
+
* Should include:
|
|
67
|
+
* - What the rule does
|
|
68
|
+
* - Why it's useful
|
|
69
|
+
* - Examples of incorrect and correct code
|
|
70
|
+
* - Configuration options explained
|
|
71
|
+
*/
|
|
72
|
+
docs: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Helper to define rule metadata with type safety
|
|
76
|
+
*/
|
|
77
|
+
declare function defineRuleMeta(meta: RuleMeta): RuleMeta;
|
|
12
78
|
|
|
13
79
|
/**
|
|
14
80
|
* Styleguide loader for the LLM semantic rule
|
|
@@ -139,74 +205,36 @@ declare function clearCache(): void;
|
|
|
139
205
|
* Rule Registry
|
|
140
206
|
*
|
|
141
207
|
* Central registry of all UILint ESLint rules with metadata for CLI tooling.
|
|
142
|
-
*
|
|
143
|
-
*
|
|
208
|
+
* Metadata is now colocated with each rule file - this module re-exports
|
|
209
|
+
* the collected metadata for use by installers and other tools.
|
|
144
210
|
*/
|
|
145
|
-
|
|
146
|
-
* Schema for prompting user to configure a rule option
|
|
147
|
-
*/
|
|
148
|
-
interface OptionFieldSchema {
|
|
149
|
-
/** Field name in the options object */
|
|
150
|
-
key: string;
|
|
151
|
-
/** Display label for the prompt */
|
|
152
|
-
label: string;
|
|
153
|
-
/** Prompt type */
|
|
154
|
-
type: "text" | "number" | "boolean" | "select" | "multiselect";
|
|
155
|
-
/** Default value */
|
|
156
|
-
defaultValue: unknown;
|
|
157
|
-
/** Placeholder text (for text/number inputs) */
|
|
158
|
-
placeholder?: string;
|
|
159
|
-
/** Options for select/multiselect */
|
|
160
|
-
options?: Array<{
|
|
161
|
-
value: string | number;
|
|
162
|
-
label: string;
|
|
163
|
-
}>;
|
|
164
|
-
/** Description/hint for the field */
|
|
165
|
-
description?: string;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Schema describing how to prompt for rule options during installation
|
|
169
|
-
*/
|
|
170
|
-
interface RuleOptionSchema {
|
|
171
|
-
/** Fields that can be configured for this rule */
|
|
172
|
-
fields: OptionFieldSchema[];
|
|
173
|
-
}
|
|
174
|
-
interface RuleMetadata {
|
|
175
|
-
/** Rule identifier (e.g., "no-arbitrary-tailwind") */
|
|
176
|
-
id: string;
|
|
177
|
-
/** Display name for CLI */
|
|
178
|
-
name: string;
|
|
179
|
-
/** Short description for CLI selection prompts */
|
|
180
|
-
description: string;
|
|
181
|
-
/** Default severity level */
|
|
182
|
-
defaultSeverity: "error" | "warn" | "off";
|
|
183
|
-
/** Default options for the rule */
|
|
184
|
-
defaultOptions?: unknown[];
|
|
185
|
-
/** Schema for prompting user to configure options during install */
|
|
186
|
-
optionSchema?: RuleOptionSchema;
|
|
187
|
-
/** Whether this rule requires a styleguide file */
|
|
188
|
-
requiresStyleguide?: boolean;
|
|
189
|
-
/** Category for grouping */
|
|
190
|
-
category: "static" | "semantic";
|
|
191
|
-
}
|
|
211
|
+
|
|
192
212
|
/**
|
|
193
213
|
* Registry of all available UILint ESLint rules
|
|
194
214
|
*
|
|
195
215
|
* When adding a new rule:
|
|
196
|
-
* 1.
|
|
197
|
-
* 2.
|
|
198
|
-
* 3.
|
|
199
|
-
* 4.
|
|
216
|
+
* 1. Create the rule file in src/rules/
|
|
217
|
+
* 2. Export a `meta` object using `defineRuleMeta()`
|
|
218
|
+
* 3. Import and add the meta to this array
|
|
219
|
+
* 4. Run `pnpm generate:index` to regenerate exports
|
|
200
220
|
*/
|
|
201
|
-
declare const ruleRegistry:
|
|
221
|
+
declare const ruleRegistry: RuleMeta[];
|
|
202
222
|
/**
|
|
203
223
|
* Get rule metadata by ID
|
|
204
224
|
*/
|
|
205
|
-
declare function getRuleMetadata(id: string):
|
|
225
|
+
declare function getRuleMetadata(id: string): RuleMeta | undefined;
|
|
206
226
|
/**
|
|
207
227
|
* Get all rules in a category
|
|
208
228
|
*/
|
|
209
|
-
declare function getRulesByCategory(category: "static" | "semantic"):
|
|
229
|
+
declare function getRulesByCategory(category: "static" | "semantic"): RuleMeta[];
|
|
230
|
+
/**
|
|
231
|
+
* Get documentation for a rule (useful for CLI help commands)
|
|
232
|
+
*/
|
|
233
|
+
declare function getRuleDocs(id: string): string | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* Get all rule IDs
|
|
236
|
+
*/
|
|
237
|
+
declare function getAllRuleIds(): string[];
|
|
210
238
|
|
|
211
239
|
/**
|
|
212
240
|
* All available rules
|
|
@@ -337,4 +365,4 @@ interface UILintESLint {
|
|
|
337
365
|
*/
|
|
338
366
|
declare const uilintEslint: UILintESLint;
|
|
339
367
|
|
|
340
|
-
export { type CacheEntry, type CacheStore, type CachedIssue, type LibraryName, type OptionFieldSchema, type RuleMetadata, type RuleOptionSchema, type UILintESLint, clearCache$1 as clearCache, clearCacheEntry, clearCache as clearImportGraphCache, configs, createRule, uilintEslint as default, findStyleguidePath, getCacheEntry, getComponentLibrary, getRuleMetadata, getRulesByCategory, getStyleguide, hashContent, hashContentSync, loadCache, loadStyleguide, meta, plugin, ruleRegistry, rules, saveCache, setCacheEntry };
|
|
368
|
+
export { type CacheEntry, type CacheStore, type CachedIssue, type LibraryName, type OptionFieldSchema, type RuleMeta, type RuleMeta as RuleMetadata, type RuleOptionSchema, type UILintESLint, clearCache$1 as clearCache, clearCacheEntry, clearCache as clearImportGraphCache, configs, createRule, uilintEslint as default, defineRuleMeta, findStyleguidePath, getAllRuleIds, getCacheEntry, getComponentLibrary, getRuleDocs, getRuleMetadata, getRulesByCategory, getStyleguide, hashContent, hashContentSync, loadCache, loadStyleguide, meta, plugin, ruleRegistry, rules, saveCache, setCacheEntry };
|