uilint 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uilint",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "CLI for UILint - AI-powered UI consistency checking",
5
5
  "author": "Peter Suggate",
6
6
  "repository": {
@@ -43,8 +43,8 @@
43
43
  "magicast": "^0.3.5",
44
44
  "picocolors": "^1.1.1",
45
45
  "ws": "^8.18.0",
46
- "uilint-core": "0.2.3",
47
- "uilint-eslint": "0.2.3"
46
+ "uilint-core": "0.2.4",
47
+ "uilint-eslint": "0.2.4"
48
48
  },
49
49
  "optionalDependencies": {
50
50
  "@langfuse/client": "^4.5.1",
@@ -77,6 +77,7 @@
77
77
  "typecheck": "tsc --noEmit",
78
78
  "lint": "eslint src/",
79
79
  "test": "vitest",
80
+ "test:watch": "vitest --watch",
80
81
  "test:unit": "vitest run test/unit",
81
82
  "test:integration": "vitest run test/integration"
82
83
  }
@@ -13,7 +13,7 @@ metadata:
13
13
  version: "1.0.0"
14
14
  category: react-eslint
15
15
  compatibility: |
16
- Requires Node.js 20+, TypeScript project with @typescript-eslint/utils,
16
+ Requires TypeScript project with @typescript-eslint,
17
17
  and uilint-eslint package installed.
18
18
  ---
19
19
 
@@ -56,21 +56,22 @@ Ask clarifying questions if needed before proceeding.
56
56
 
57
57
  ### Step 2: Analyze Existing Rules
58
58
 
59
- Look at the existing uilint-eslint rules for patterns:
59
+ Look at existing rules installed in the project for patterns:
60
60
 
61
61
  ```bash
62
- ls packages/uilint-eslint/src/rules/
62
+ ls .uilint/rules/
63
63
  ```
64
64
 
65
- Read similar rules to understand the codebase patterns:
66
- - `prefer-zustand-state-management.ts` - component analysis, hook counting
67
- - `no-mixed-component-libraries.ts` - cross-file analysis, import tracking
68
- - `consistent-spacing.ts` - className/Tailwind pattern matching
69
- - `consistent-dark-mode.ts` - attribute analysis in JSX
65
+ If no rules exist yet, you can reference examples from the uilint-eslint package or look at similar patterns. Common rule patterns include:
66
+
67
+ - Component analysis and hook counting
68
+ - Cross-file analysis and import tracking
69
+ - className/Tailwind pattern matching
70
+ - Attribute analysis in JSX
70
71
 
71
72
  ### Step 3: Write the Rule
72
73
 
73
- Create the rule file at `packages/uilint-eslint/src/rules/{rule-name}.ts`.
74
+ Create the rule file at `.uilint/rules/{rule-name}.ts` in the target project.
74
75
 
75
76
  Follow this structure exactly:
76
77
 
@@ -81,7 +82,7 @@ Follow this structure exactly:
81
82
  * {Description of what this rule does and why}
82
83
  */
83
84
 
84
- import { createRule } from "../utils/create-rule.js";
85
+ import { createRule } from "uilint-eslint";
85
86
  import type { TSESTree } from "@typescript-eslint/utils";
86
87
 
87
88
  type MessageIds = "{messageId1}" | "{messageId2}";
@@ -143,7 +144,7 @@ export default createRule<Options, MessageIds>({
143
144
 
144
145
  ### Step 4: Write Comprehensive Tests
145
146
 
146
- Create the test file at `packages/uilint-eslint/src/rules/{rule-name}.test.ts`.
147
+ Create the test file at `.uilint/rules/{rule-name}.test.ts` in the target project.
147
148
 
148
149
  Follow this structure:
149
150
 
@@ -239,45 +240,32 @@ ruleTester.run("{rule-name}", rule, {
239
240
  });
240
241
  ```
241
242
 
242
- ### Step 5: Register the Rule
243
+ ### Step 5: Configure ESLint to Use the Rule
243
244
 
244
- Add the rule to `packages/uilint-eslint/src/rule-registry.ts`:
245
+ The rule will be automatically configured in your `eslint.config.{js,ts,mjs,cjs}` file. The installer creates a custom plugin that references your local rules:
245
246
 
246
- ```typescript
247
- {
248
- id: "{rule-name}",
249
- name: "{Display Name}",
250
- description: "{Short description for CLI}",
251
- defaultSeverity: "warn" | "error",
252
- defaultOptions: [{ /* defaults */ }],
253
- optionSchema: {
254
- fields: [
255
- {
256
- key: "optionName",
257
- label: "Option Label",
258
- type: "select" | "text" | "boolean" | "number",
259
- defaultValue: "default",
260
- options: [{ value: "x", label: "X" }], // for select
261
- description: "Help text",
247
+ ```javascript
248
+ import { createRule } from "uilint-eslint";
249
+ import yourRuleName from "./.uilint/rules/your-rule-name.js";
250
+
251
+ export default [
252
+ // ... existing config
253
+ {
254
+ plugins: {
255
+ "uilint-custom": {
256
+ rules: {
257
+ "your-rule-name": yourRuleName,
258
+ },
262
259
  },
263
- ],
260
+ },
261
+ rules: {
262
+ "uilint-custom/your-rule-name": "error",
263
+ },
264
264
  },
265
- category: "static",
266
- },
265
+ ];
267
266
  ```
268
267
 
269
- ### Step 6: Regenerate Index and Test
270
-
271
- ```bash
272
- # Regenerate the index file
273
- pnpm -C packages/uilint-eslint generate:index
274
-
275
- # Run the tests
276
- pnpm -C packages/uilint-eslint test
277
-
278
- # Build to verify
279
- pnpm -C packages/uilint-eslint build
280
- ```
268
+ If you're creating the rule manually (not via the installer), you'll need to add the import and configure it in your ESLint config.
281
269
 
282
270
  ## Common AST Patterns
283
271
 
@@ -401,6 +389,7 @@ import { getComponentLibrary, clearCache } from "../utils/import-graph.js";
401
389
  3. Use placeholders for dynamic content
402
390
 
403
391
  Good:
392
+
404
393
  ```typescript
405
394
  messages: {
406
395
  useDesignSystem:
@@ -409,6 +398,7 @@ messages: {
409
398
  ```
410
399
 
411
400
  Bad:
401
+
412
402
  ```typescript
413
403
  messages: {
414
404
  error: "Invalid element", // Too vague
@@ -435,11 +425,11 @@ See the following files for complete working examples:
435
425
 
436
426
  Before finishing, verify:
437
427
 
438
- - [ ] Rule file created at `packages/uilint-eslint/src/rules/{name}.ts`
439
- - [ ] Test file created at `packages/uilint-eslint/src/rules/{name}.test.ts`
440
- - [ ] Rule added to `packages/uilint-eslint/src/rule-registry.ts`
441
- - [ ] Index regenerated with `pnpm -C packages/uilint-eslint generate:index`
442
- - [ ] All tests pass with `pnpm -C packages/uilint-eslint test`
443
- - [ ] Build succeeds with `pnpm -C packages/uilint-eslint build`
428
+ - [ ] Rule file created at `.uilint/rules/{name}.ts`
429
+ - [ ] Test file created at `.uilint/rules/{name}.test.ts` (if applicable)
430
+ - [ ] Rule imports `createRule` from `"uilint-eslint"`
431
+ - [ ] ESLint config updated to import and use the rule from `.uilint/rules/`
432
+ - [ ] Rule configured in ESLint with appropriate severity
444
433
  - [ ] Error messages are clear and actionable
445
434
  - [ ] Configuration options are documented in schema
435
+ - [ ] Rule works correctly when ESLint runs