zemdomu 1.3.2 → 1.3.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 (61) hide show
  1. package/out/cli.d.ts +2 -0
  2. package/out/cli.js +88 -0
  3. package/out/component-analyzer.d.ts +89 -0
  4. package/out/component-analyzer.js +620 -0
  5. package/out/component-path-resolver.d.ts +19 -0
  6. package/out/component-path-resolver.js +259 -0
  7. package/out/html-visitor.d.ts +5 -0
  8. package/out/html-visitor.js +13 -0
  9. package/out/index.d.ts +14 -0
  10. package/out/index.js +25 -0
  11. package/out/linter.d.ts +38 -0
  12. package/out/linter.js +272 -0
  13. package/out/performance-diagnostics.d.ts +14 -0
  14. package/out/performance-diagnostics.js +47 -0
  15. package/out/project-linter.d.ts +16 -0
  16. package/out/project-linter.js +114 -0
  17. package/out/rules/enforceHeadingOrder.d.ts +2 -0
  18. package/out/rules/enforceHeadingOrder.js +39 -0
  19. package/out/rules/enforceListNesting.d.ts +2 -0
  20. package/out/rules/enforceListNesting.js +81 -0
  21. package/out/rules/noTabindexGreaterThanZero.d.ts +2 -0
  22. package/out/rules/noTabindexGreaterThanZero.js +33 -0
  23. package/out/rules/preventEmptyInlineTags.d.ts +2 -0
  24. package/out/rules/preventEmptyInlineTags.js +85 -0
  25. package/out/rules/requireAltText.d.ts +2 -0
  26. package/out/rules/requireAltText.js +78 -0
  27. package/out/rules/requireAltTextJSX.d.ts +4 -0
  28. package/out/rules/requireAltTextJSX.js +63 -0
  29. package/out/rules/requireButtonText.d.ts +2 -0
  30. package/out/rules/requireButtonText.js +78 -0
  31. package/out/rules/requireHrefOnAnchors.d.ts +2 -0
  32. package/out/rules/requireHrefOnAnchors.js +66 -0
  33. package/out/rules/requireHtmlLang.d.ts +2 -0
  34. package/out/rules/requireHtmlLang.js +72 -0
  35. package/out/rules/requireIframeTitle.d.ts +2 -0
  36. package/out/rules/requireIframeTitle.js +69 -0
  37. package/out/rules/requireImageInputAlt.d.ts +2 -0
  38. package/out/rules/requireImageInputAlt.js +69 -0
  39. package/out/rules/requireLabelForFormControls.d.ts +2 -0
  40. package/out/rules/requireLabelForFormControls.js +84 -0
  41. package/out/rules/requireLinkText.d.ts +2 -0
  42. package/out/rules/requireLinkText.js +101 -0
  43. package/out/rules/requireNavLinks.d.ts +2 -0
  44. package/out/rules/requireNavLinks.js +88 -0
  45. package/out/rules/requireSectionHeading.d.ts +2 -0
  46. package/out/rules/requireSectionHeading.js +48 -0
  47. package/out/rules/requireTableCaption.d.ts +2 -0
  48. package/out/rules/requireTableCaption.js +48 -0
  49. package/out/rules/singleH1.d.ts +2 -0
  50. package/out/rules/singleH1.js +33 -0
  51. package/out/rules/uniqueIds.d.ts +2 -0
  52. package/out/rules/uniqueIds.js +33 -0
  53. package/out/rules/utils.d.ts +6 -0
  54. package/out/rules/utils.js +50 -0
  55. package/out/sarif.d.ts +38 -0
  56. package/out/sarif.js +54 -0
  57. package/out/simpleHtmlParser.d.ts +20 -0
  58. package/out/simpleHtmlParser.js +82 -0
  59. package/out/utils/collectLocalDeps.d.ts +7 -0
  60. package/out/utils/collectLocalDeps.js +132 -0
  61. package/package.json +10 -7
package/out/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/out/cli.js ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const glob_1 = __importDefault(require("glob"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const project_linter_1 = require("./project-linter");
10
+ function parsePatterns(inputs) {
11
+ const result = [];
12
+ for (const input of inputs) {
13
+ const splits = input
14
+ .split(/\r?\n/)
15
+ .flatMap((p) => p.split(/[ ,]+/))
16
+ .filter(Boolean);
17
+ result.push(...splits);
18
+ }
19
+ return result;
20
+ }
21
+ async function run() {
22
+ var _a;
23
+ const args = process.argv.slice(2);
24
+ const rawPatterns = [];
25
+ const customRules = [];
26
+ let cross = false;
27
+ let depth;
28
+ for (let i = 0; i < args.length; i++) {
29
+ const arg = args[i];
30
+ if (arg === '--custom' || arg === '-c') {
31
+ const file = args[++i];
32
+ if (!file)
33
+ throw new Error('Missing file for --custom');
34
+ const resolved = path_1.default.resolve(file);
35
+ const customDir = path_1.default.resolve('custom-rules');
36
+ const relative = path_1.default.relative(customDir, resolved);
37
+ if (relative.startsWith('..') || path_1.default.isAbsolute(relative)) {
38
+ throw new Error('Custom rule file must be inside ./custom-rules');
39
+ }
40
+ const mod = require(resolved);
41
+ const rules = (_a = mod.default) !== null && _a !== void 0 ? _a : mod;
42
+ if (Array.isArray(rules))
43
+ customRules.push(...rules);
44
+ else
45
+ customRules.push(rules);
46
+ }
47
+ else if (arg === '--cross') {
48
+ cross = true;
49
+ }
50
+ else if (arg === '--cross-depth') {
51
+ const val = args[++i];
52
+ if (!val)
53
+ throw new Error('Missing value for --cross-depth');
54
+ depth = parseInt(val, 10);
55
+ if (isNaN(depth))
56
+ throw new Error('Invalid number for --cross-depth');
57
+ cross = true;
58
+ }
59
+ else {
60
+ rawPatterns.push(arg);
61
+ }
62
+ }
63
+ const patterns = parsePatterns(rawPatterns);
64
+ if (patterns.length === 0) {
65
+ patterns.push('**/*.{html,jsx,tsx}');
66
+ }
67
+ const files = new Set();
68
+ for (const pattern of patterns) {
69
+ const matches = glob_1.default.sync(pattern, { nodir: true });
70
+ for (const m of matches)
71
+ files.add(m);
72
+ }
73
+ const linter = new project_linter_1.ProjectLinter({ customRules, crossComponentAnalysis: cross, crossComponentDepth: depth });
74
+ const results = await linter.lintFiles(Array.from(files));
75
+ let hasIssues = false;
76
+ for (const [file, issues] of results.entries()) {
77
+ for (const issue of issues) {
78
+ console.error(`${file}:${issue.line + 1}:${issue.column + 1} ${issue.rule}: ${issue.message}`);
79
+ hasIssues = true;
80
+ }
81
+ }
82
+ if (hasIssues)
83
+ process.exit(1);
84
+ }
85
+ run().catch((e) => {
86
+ console.error(e);
87
+ process.exit(1);
88
+ });
@@ -0,0 +1,89 @@
1
+ import { LintResult, LinterOptions } from './linter';
2
+ interface PerformanceRecorder {
3
+ record(filePath: string, timings: Record<string, number>): void;
4
+ }
5
+ interface ComponentReference {
6
+ name: string;
7
+ path: string | null;
8
+ rawImportPath: string | null;
9
+ sourceLocation: {
10
+ line: number;
11
+ column: number;
12
+ };
13
+ usageLocations: Array<{
14
+ line: number;
15
+ column: number;
16
+ }>;
17
+ }
18
+ interface HeadingInfo {
19
+ level: number;
20
+ line: number;
21
+ column: number;
22
+ filePath: string;
23
+ }
24
+ interface IdInfo {
25
+ id: string;
26
+ line: number;
27
+ column: number;
28
+ filePath: string;
29
+ }
30
+ interface NavInfo {
31
+ filePath: string;
32
+ line: number;
33
+ column: number;
34
+ hasLocalLink: boolean;
35
+ childComponents: ComponentReference[];
36
+ }
37
+ interface ComponentDefinition {
38
+ name: string;
39
+ filePath: string;
40
+ issues: Map<string, LintResult[]>;
41
+ usesComponents: ComponentReference[];
42
+ headings: HeadingInfo[];
43
+ ids: IdInfo[];
44
+ navs: NavInfo[];
45
+ hasLocalAnchor: boolean;
46
+ }
47
+ export declare class ComponentAnalyzer {
48
+ private componentRegistry;
49
+ private importToComponentMap;
50
+ private options;
51
+ private processingComponentStack;
52
+ private perf?;
53
+ private resolver;
54
+ private maxDepth;
55
+ constructor(options: LinterOptions & {
56
+ crossComponentAnalysis?: boolean;
57
+ crossComponentDepth?: number;
58
+ }, perf?: PerformanceRecorder);
59
+ analyzeFile(filePath: string): Promise<ComponentDefinition | null>;
60
+ private extractComponentInfo;
61
+ private resolveComponentPath;
62
+ registerComponent(component: ComponentDefinition, issues: LintResult[]): void;
63
+ private getRuleType;
64
+ analyzeComponentTree(): LintResult[];
65
+ private findCrossComponentH1Issues;
66
+ private findReferenceForComp;
67
+ /**
68
+ * Improved implementation to find heading order issues across components
69
+ */
70
+ private findCrossComponentHeadingOrderIssues;
71
+ /**
72
+ * Collects all headings from a component and its children in document order
73
+ * and checks for heading level issues
74
+ */
75
+ private analyzeHeadingHierarchy;
76
+ /**
77
+ * Collects all headings from a component and its children in document order
78
+ */
79
+ private collectHeadingsInDocumentOrder;
80
+ private findCrossComponentDuplicateIds;
81
+ private collectIds;
82
+ private findCrossComponentNavLinks;
83
+ private checkNavs;
84
+ private navHasLink;
85
+ private componentHasAnchor;
86
+ private findEntryPoints;
87
+ private findComponentsWithRule;
88
+ }
89
+ export {};