uilint-eslint 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.
Files changed (42) hide show
  1. package/dist/chunk-IL6RYCMD.js +10 -0
  2. package/dist/chunk-IL6RYCMD.js.map +1 -0
  3. package/dist/index.d.ts +51 -14
  4. package/dist/index.js +13 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/rules/consistent-dark-mode.js +341 -0
  7. package/dist/rules/consistent-dark-mode.js.map +1 -0
  8. package/dist/rules/consistent-spacing.js +172 -0
  9. package/dist/rules/consistent-spacing.js.map +1 -0
  10. package/dist/rules/no-arbitrary-tailwind.js +78 -0
  11. package/dist/rules/no-arbitrary-tailwind.js.map +1 -0
  12. package/dist/rules/no-direct-store-import.js +71 -0
  13. package/dist/rules/no-direct-store-import.js.map +1 -0
  14. package/dist/rules/no-mixed-component-libraries.js +616 -0
  15. package/dist/rules/no-mixed-component-libraries.js.map +1 -0
  16. package/dist/rules/prefer-zustand-state-management.js +185 -0
  17. package/dist/rules/prefer-zustand-state-management.js.map +1 -0
  18. package/dist/rules/semantic-vision.js +152 -0
  19. package/dist/rules/semantic-vision.js.map +1 -0
  20. package/dist/rules/semantic.js +387 -0
  21. package/dist/rules/semantic.js.map +1 -0
  22. package/package.json +3 -2
  23. package/src/index.ts +273 -0
  24. package/src/rule-registry.ts +285 -0
  25. package/src/rules/consistent-dark-mode.test.ts +832 -0
  26. package/src/rules/consistent-dark-mode.ts +462 -0
  27. package/src/rules/consistent-spacing.ts +175 -0
  28. package/src/rules/no-arbitrary-tailwind.ts +107 -0
  29. package/src/rules/no-direct-store-import.ts +93 -0
  30. package/src/rules/no-mixed-component-libraries.test.ts +383 -0
  31. package/src/rules/no-mixed-component-libraries.ts +198 -0
  32. package/src/rules/prefer-zustand-state-management.test.ts +842 -0
  33. package/src/rules/prefer-zustand-state-management.ts +324 -0
  34. package/src/rules/semantic-vision.ts +264 -0
  35. package/src/rules/semantic.ts +327 -0
  36. package/src/utils/cache.ts +175 -0
  37. package/src/utils/component-parser.ts +368 -0
  38. package/src/utils/create-rule.ts +10 -0
  39. package/src/utils/export-resolver.ts +348 -0
  40. package/src/utils/import-graph.test.ts +420 -0
  41. package/src/utils/import-graph.ts +232 -0
  42. package/src/utils/styleguide-loader.ts +143 -0
@@ -0,0 +1,10 @@
1
+ // src/utils/create-rule.ts
2
+ import { ESLintUtils } from "@typescript-eslint/utils";
3
+ var createRule = ESLintUtils.RuleCreator(
4
+ (name) => `https://github.com/peter-suggate/uilint/blob/main/packages/uilint-eslint/docs/rules/${name}.md`
5
+ );
6
+
7
+ export {
8
+ createRule
9
+ };
10
+ //# sourceMappingURL=chunk-IL6RYCMD.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"],"mappings":";AAIA,SAAS,mBAAmB;AAErB,IAAM,aAAa,YAAY;AAAA,EACpC,CAAC,SACC,uFAAuF,IAAI;AAC/F;","names":[]}
package/dist/index.d.ts CHANGED
@@ -2,18 +2,6 @@ import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts
2
2
  import { Linter } from 'eslint';
3
3
  import { ESLintUtils } from '@typescript-eslint/utils';
4
4
 
5
- /**
6
- * Component Parser
7
- *
8
- * Parses a single component's body to extract styling information
9
- * and identify nested component usage.
10
- */
11
-
12
- /**
13
- * Known UI library import patterns
14
- */
15
- type LibraryName = "shadcn" | "mui" | "chakra" | "antd";
16
-
17
5
  /**
18
6
  * Rule creation helper using @typescript-eslint/utils
19
7
  */
@@ -96,7 +84,56 @@ declare function clearCacheEntry(projectRoot: string, filePath: string): void;
96
84
  /**
97
85
  * Clear entire cache
98
86
  */
99
- declare function clearCache(projectRoot: string): void;
87
+ declare function clearCache$1(projectRoot: string): void;
88
+
89
+ /**
90
+ * Component Parser
91
+ *
92
+ * Parses a single component's body to extract styling information
93
+ * and identify nested component usage.
94
+ */
95
+
96
+ /**
97
+ * Known UI library import patterns
98
+ */
99
+ type LibraryName = "shadcn" | "mui" | "chakra" | "antd";
100
+
101
+ /**
102
+ * Import Graph Service
103
+ *
104
+ * Provides demand-driven cross-file analysis to detect UI library usage
105
+ * across component trees. Uses in-memory caching for performance.
106
+ */
107
+
108
+ /**
109
+ * Information about a component's UI library usage
110
+ */
111
+ interface ComponentLibraryInfo {
112
+ /** Direct library (from import source, e.g., "@mui/material" -> "mui") */
113
+ library: LibraryName | null;
114
+ /** Libraries used internally by this component (for local components) */
115
+ internalLibraries: Set<LibraryName>;
116
+ /** Evidence of which internal components caused the library detection */
117
+ libraryEvidence: Array<{
118
+ componentName: string;
119
+ library: LibraryName;
120
+ }>;
121
+ /** Whether this is a local component (resolved from project files) */
122
+ isLocalComponent: boolean;
123
+ }
124
+ /**
125
+ * Analyze a component's library usage, including transitive dependencies
126
+ *
127
+ * @param contextFilePath - The file where the component is used (for resolving relative imports)
128
+ * @param componentName - The name of the component (e.g., "Button", "MyCard")
129
+ * @param importSource - The import source (e.g., "@mui/material", "./components/cards")
130
+ * @returns Library information including direct and transitive library usage
131
+ */
132
+ declare function getComponentLibrary(contextFilePath: string, componentName: string, importSource: string): ComponentLibraryInfo;
133
+ /**
134
+ * Clear all caches (useful for testing or between ESLint runs)
135
+ */
136
+ declare function clearCache(): void;
100
137
 
101
138
  /**
102
139
  * Rule Registry
@@ -300,4 +337,4 @@ interface UILintESLint {
300
337
  */
301
338
  declare const uilintEslint: UILintESLint;
302
339
 
303
- export { type CacheEntry, type CacheStore, type CachedIssue, type OptionFieldSchema, type RuleMetadata, type RuleOptionSchema, type UILintESLint, clearCache, clearCacheEntry, configs, createRule, uilintEslint as default, findStyleguidePath, getCacheEntry, getRuleMetadata, getRulesByCategory, getStyleguide, hashContent, hashContentSync, loadCache, loadStyleguide, meta, plugin, ruleRegistry, rules, saveCache, setCacheEntry };
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 };
package/dist/index.js CHANGED
@@ -1004,6 +1004,11 @@ function resolveExport(exportName, filePath, visited = /* @__PURE__ */ new Set()
1004
1004
  isReexport: false
1005
1005
  };
1006
1006
  }
1007
+ function clearResolverCaches() {
1008
+ exportCache.clear();
1009
+ astCache.clear();
1010
+ resolvedPathCache.clear();
1011
+ }
1007
1012
 
1008
1013
  // src/utils/component-parser.ts
1009
1014
  var LIBRARY_PATTERNS = {
@@ -1298,6 +1303,10 @@ function analyzeComponentLibraries(filePath, componentName, visited) {
1298
1303
  isLocalComponent: true
1299
1304
  };
1300
1305
  }
1306
+ function clearCache() {
1307
+ componentLibraryCache.clear();
1308
+ clearResolverCaches();
1309
+ }
1301
1310
 
1302
1311
  // src/rules/no-mixed-component-libraries.ts
1303
1312
  var no_mixed_component_libraries_default = createRule({
@@ -1510,7 +1519,7 @@ function clearCacheEntry(projectRoot, filePath) {
1510
1519
  delete cache.entries[filePath];
1511
1520
  saveCache(projectRoot, cache);
1512
1521
  }
1513
- function clearCache(projectRoot) {
1522
+ function clearCache2(projectRoot) {
1514
1523
  saveCache(projectRoot, { version: CACHE_VERSION, entries: {} });
1515
1524
  }
1516
1525
 
@@ -2350,13 +2359,15 @@ var uilintEslint = {
2350
2359
  };
2351
2360
  var index_default = uilintEslint;
2352
2361
  export {
2353
- clearCache,
2362
+ clearCache2 as clearCache,
2354
2363
  clearCacheEntry,
2364
+ clearCache as clearImportGraphCache,
2355
2365
  configs,
2356
2366
  createRule,
2357
2367
  index_default as default,
2358
2368
  findStyleguidePath,
2359
2369
  getCacheEntry,
2370
+ getComponentLibrary,
2360
2371
  getRuleMetadata,
2361
2372
  getRulesByCategory,
2362
2373
  getStyleguide,