@terra-symposium/hygiene 0.0.0-stage → 2.4.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/README.md +70 -2
- package/dist/accessibility.d.ts +39 -0
- package/dist/accessibility.d.ts.map +1 -0
- package/dist/accessibility.js +524 -0
- package/dist/accessibility.js.map +1 -0
- package/dist/app/workspace-test-runner.d.ts +6 -0
- package/dist/app/workspace-test-runner.d.ts.map +1 -0
- package/dist/app/workspace-test-runner.js +39 -0
- package/dist/app/workspace-test-runner.js.map +1 -0
- package/dist/capabilities/core/analysis.d.ts +22 -0
- package/dist/capabilities/core/analysis.d.ts.map +1 -0
- package/dist/capabilities/core/analysis.js +44 -0
- package/dist/capabilities/core/analysis.js.map +1 -0
- package/dist/capabilities/core/cli.d.ts +19 -0
- package/dist/capabilities/core/cli.d.ts.map +1 -0
- package/dist/capabilities/core/cli.js +58 -0
- package/dist/capabilities/core/cli.js.map +1 -0
- package/dist/capabilities/core/config.d.ts +49 -0
- package/dist/capabilities/core/config.d.ts.map +1 -0
- package/dist/capabilities/core/config.js +88 -0
- package/dist/capabilities/core/config.js.map +1 -0
- package/dist/capabilities/core/index.d.ts +11 -0
- package/dist/capabilities/core/index.d.ts.map +1 -0
- package/dist/capabilities/core/index.js +11 -0
- package/dist/capabilities/core/index.js.map +1 -0
- package/dist/capabilities/core/lib/files.d.ts +55 -0
- package/dist/capabilities/core/lib/files.d.ts.map +1 -0
- package/dist/capabilities/core/lib/files.js +287 -0
- package/dist/capabilities/core/lib/files.js.map +1 -0
- package/dist/capabilities/core/lib/progress.d.ts +25 -0
- package/dist/capabilities/core/lib/progress.d.ts.map +1 -0
- package/dist/capabilities/core/lib/progress.js +40 -0
- package/dist/capabilities/core/lib/progress.js.map +1 -0
- package/dist/capabilities/core/lib/source-kind.d.ts +14 -0
- package/dist/capabilities/core/lib/source-kind.d.ts.map +1 -0
- package/dist/capabilities/core/lib/source-kind.js +29 -0
- package/dist/capabilities/core/lib/source-kind.js.map +1 -0
- package/dist/capabilities/core/types.d.ts +156 -0
- package/dist/capabilities/core/types.d.ts.map +1 -0
- package/dist/capabilities/core/types.js +35 -0
- package/dist/capabilities/core/types.js.map +1 -0
- package/dist/capabilities/documentation/cli.d.ts +3 -0
- package/dist/capabilities/documentation/cli.d.ts.map +1 -0
- package/dist/capabilities/documentation/cli.js +14 -0
- package/dist/capabilities/documentation/cli.js.map +1 -0
- package/dist/capabilities/documentation/index.d.ts +5 -0
- package/dist/capabilities/documentation/index.d.ts.map +1 -0
- package/dist/capabilities/documentation/index.js +5 -0
- package/dist/capabilities/documentation/index.js.map +1 -0
- package/dist/capabilities/documentation/lib/documentation.d.ts +108 -0
- package/dist/capabilities/documentation/lib/documentation.d.ts.map +1 -0
- package/dist/capabilities/documentation/lib/documentation.js +1007 -0
- package/dist/capabilities/documentation/lib/documentation.js.map +1 -0
- package/dist/capabilities/formatting/cli.d.ts +3 -0
- package/dist/capabilities/formatting/cli.d.ts.map +1 -0
- package/dist/capabilities/formatting/cli.js +15 -0
- package/dist/capabilities/formatting/cli.js.map +1 -0
- package/dist/capabilities/formatting/index.d.ts +8 -0
- package/dist/capabilities/formatting/index.d.ts.map +1 -0
- package/dist/capabilities/formatting/index.js +8 -0
- package/dist/capabilities/formatting/index.js.map +1 -0
- package/dist/capabilities/formatting/lib/collapse.d.ts +13 -0
- package/dist/capabilities/formatting/lib/collapse.d.ts.map +1 -0
- package/dist/capabilities/formatting/lib/collapse.js +179 -0
- package/dist/capabilities/formatting/lib/collapse.js.map +1 -0
- package/dist/capabilities/formatting/lib/inline-if.d.ts +13 -0
- package/dist/capabilities/formatting/lib/inline-if.d.ts.map +1 -0
- package/dist/capabilities/formatting/lib/inline-if.js +49 -0
- package/dist/capabilities/formatting/lib/inline-if.js.map +1 -0
- package/dist/capabilities/formatting/lib/run-formatting.d.ts +14 -0
- package/dist/capabilities/formatting/lib/run-formatting.d.ts.map +1 -0
- package/dist/capabilities/formatting/lib/run-formatting.js +134 -0
- package/dist/capabilities/formatting/lib/run-formatting.js.map +1 -0
- package/dist/capabilities/imports/cli.d.ts +3 -0
- package/dist/capabilities/imports/cli.d.ts.map +1 -0
- package/dist/capabilities/imports/cli.js +9 -0
- package/dist/capabilities/imports/cli.js.map +1 -0
- package/dist/capabilities/imports/index.d.ts +6 -0
- package/dist/capabilities/imports/index.d.ts.map +1 -0
- package/dist/capabilities/imports/index.js +6 -0
- package/dist/capabilities/imports/index.js.map +1 -0
- package/dist/capabilities/imports/lib/imports.d.ts +19 -0
- package/dist/capabilities/imports/lib/imports.d.ts.map +1 -0
- package/dist/capabilities/imports/lib/imports.js +88 -0
- package/dist/capabilities/imports/lib/imports.js.map +1 -0
- package/dist/capabilities/languages/cli.d.ts +3 -0
- package/dist/capabilities/languages/cli.d.ts.map +1 -0
- package/dist/capabilities/languages/cli.js +9 -0
- package/dist/capabilities/languages/cli.js.map +1 -0
- package/dist/capabilities/languages/index.d.ts +6 -0
- package/dist/capabilities/languages/index.d.ts.map +1 -0
- package/dist/capabilities/languages/index.js +6 -0
- package/dist/capabilities/languages/index.js.map +1 -0
- package/dist/capabilities/languages/lib/language-profiles.d.ts +110 -0
- package/dist/capabilities/languages/lib/language-profiles.d.ts.map +1 -0
- package/dist/capabilities/languages/lib/language-profiles.js +509 -0
- package/dist/capabilities/languages/lib/language-profiles.js.map +1 -0
- package/dist/capabilities/languages/lib/run-language-checks.d.ts +12 -0
- package/dist/capabilities/languages/lib/run-language-checks.d.ts.map +1 -0
- package/dist/capabilities/languages/lib/run-language-checks.js +109 -0
- package/dist/capabilities/languages/lib/run-language-checks.js.map +1 -0
- package/dist/capabilities/naming/cli.d.ts +3 -0
- package/dist/capabilities/naming/cli.d.ts.map +1 -0
- package/dist/capabilities/naming/cli.js +15 -0
- package/dist/capabilities/naming/cli.js.map +1 -0
- package/dist/capabilities/naming/index.d.ts +5 -0
- package/dist/capabilities/naming/index.d.ts.map +1 -0
- package/dist/capabilities/naming/index.js +5 -0
- package/dist/capabilities/naming/index.js.map +1 -0
- package/dist/capabilities/naming/lib/naming.d.ts +169 -0
- package/dist/capabilities/naming/lib/naming.d.ts.map +1 -0
- package/dist/capabilities/naming/lib/naming.js +908 -0
- package/dist/capabilities/naming/lib/naming.js.map +1 -0
- package/dist/capabilities/patterns/cli.d.ts +3 -0
- package/dist/capabilities/patterns/cli.d.ts.map +1 -0
- package/dist/capabilities/patterns/cli.js +30 -0
- package/dist/capabilities/patterns/cli.js.map +1 -0
- package/dist/capabilities/patterns/index.d.ts +5 -0
- package/dist/capabilities/patterns/index.d.ts.map +1 -0
- package/dist/capabilities/patterns/index.js +5 -0
- package/dist/capabilities/patterns/index.js.map +1 -0
- package/dist/capabilities/patterns/lib/patterns.d.ts +102 -0
- package/dist/capabilities/patterns/lib/patterns.d.ts.map +1 -0
- package/dist/capabilities/patterns/lib/patterns.js +1584 -0
- package/dist/capabilities/patterns/lib/patterns.js.map +1 -0
- package/dist/capabilities/refactoring/cli.d.ts +3 -0
- package/dist/capabilities/refactoring/cli.d.ts.map +1 -0
- package/dist/capabilities/refactoring/cli.js +15 -0
- package/dist/capabilities/refactoring/cli.js.map +1 -0
- package/dist/capabilities/refactoring/index.d.ts +6 -0
- package/dist/capabilities/refactoring/index.d.ts.map +1 -0
- package/dist/capabilities/refactoring/index.js +6 -0
- package/dist/capabilities/refactoring/index.js.map +1 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.d.ts +42 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.d.ts.map +1 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.js +166 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.js.map +1 -0
- package/dist/capabilities/refactoring/lib/single-use.d.ts +61 -0
- package/dist/capabilities/refactoring/lib/single-use.d.ts.map +1 -0
- package/dist/capabilities/refactoring/lib/single-use.js +1791 -0
- package/dist/capabilities/refactoring/lib/single-use.js.map +1 -0
- package/dist/capabilities/reports/cli.d.ts +3 -0
- package/dist/capabilities/reports/cli.d.ts.map +1 -0
- package/dist/capabilities/reports/cli.js +34 -0
- package/dist/capabilities/reports/cli.js.map +1 -0
- package/dist/capabilities/reports/index.d.ts +10 -0
- package/dist/capabilities/reports/index.d.ts.map +1 -0
- package/dist/capabilities/reports/index.js +10 -0
- package/dist/capabilities/reports/index.js.map +1 -0
- package/dist/capabilities/reports/lib/github-report.d.ts +94 -0
- package/dist/capabilities/reports/lib/github-report.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/github-report.js +499 -0
- package/dist/capabilities/reports/lib/github-report.js.map +1 -0
- package/dist/capabilities/reports/lib/history-report.d.ts +58 -0
- package/dist/capabilities/reports/lib/history-report.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/history-report.js +300 -0
- package/dist/capabilities/reports/lib/history-report.js.map +1 -0
- package/dist/capabilities/reports/lib/node-reporter.d.ts +79 -0
- package/dist/capabilities/reports/lib/node-reporter.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/node-reporter.js +244 -0
- package/dist/capabilities/reports/lib/node-reporter.js.map +1 -0
- package/dist/capabilities/reports/lib/playwright-reporter.d.ts +100 -0
- package/dist/capabilities/reports/lib/playwright-reporter.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/playwright-reporter.js +122 -0
- package/dist/capabilities/reports/lib/playwright-reporter.js.map +1 -0
- package/dist/capabilities/security/cli.d.ts +3 -0
- package/dist/capabilities/security/cli.d.ts.map +1 -0
- package/dist/capabilities/security/cli.js +9 -0
- package/dist/capabilities/security/cli.js.map +1 -0
- package/dist/capabilities/security/index.d.ts +5 -0
- package/dist/capabilities/security/index.d.ts.map +1 -0
- package/dist/capabilities/security/index.js +5 -0
- package/dist/capabilities/security/index.js.map +1 -0
- package/dist/capabilities/security/lib/security.d.ts +19 -0
- package/dist/capabilities/security/lib/security.d.ts.map +1 -0
- package/dist/capabilities/security/lib/security.js +115 -0
- package/dist/capabilities/security/lib/security.js.map +1 -0
- package/dist/capabilities/ui/cli.d.ts +3 -0
- package/dist/capabilities/ui/cli.d.ts.map +1 -0
- package/dist/capabilities/ui/cli.js +22 -0
- package/dist/capabilities/ui/cli.js.map +1 -0
- package/dist/capabilities/ui/index.d.ts +8 -0
- package/dist/capabilities/ui/index.d.ts.map +1 -0
- package/dist/capabilities/ui/index.js +8 -0
- package/dist/capabilities/ui/index.js.map +1 -0
- package/dist/capabilities/ui/lib/accessibility.d.ts +37 -0
- package/dist/capabilities/ui/lib/accessibility.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/accessibility.js +676 -0
- package/dist/capabilities/ui/lib/accessibility.js.map +1 -0
- package/dist/capabilities/ui/lib/display-name.d.ts +42 -0
- package/dist/capabilities/ui/lib/display-name.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/display-name.js +277 -0
- package/dist/capabilities/ui/lib/display-name.js.map +1 -0
- package/dist/capabilities/ui/lib/error-boundaries.d.ts +30 -0
- package/dist/capabilities/ui/lib/error-boundaries.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/error-boundaries.js +401 -0
- package/dist/capabilities/ui/lib/error-boundaries.js.map +1 -0
- package/dist/capabilities/ui/lib/ui-recommendations.d.ts +45 -0
- package/dist/capabilities/ui/lib/ui-recommendations.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/ui-recommendations.js +183 -0
- package/dist/capabilities/ui/lib/ui-recommendations.js.map +1 -0
- package/dist/display-name.d.ts +44 -0
- package/dist/display-name.d.ts.map +1 -0
- package/dist/display-name.js +256 -0
- package/dist/display-name.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/accessibility.d.ts +5 -0
- package/dist/lib/accessibility.d.ts.map +1 -0
- package/dist/lib/accessibility.js +5 -0
- package/dist/lib/accessibility.js.map +1 -0
- package/dist/lib/collapse.d.ts +5 -0
- package/dist/lib/collapse.d.ts.map +1 -0
- package/dist/lib/collapse.js +5 -0
- package/dist/lib/collapse.js.map +1 -0
- package/dist/lib/dev.d.ts +3 -0
- package/dist/lib/dev.d.ts.map +1 -0
- package/dist/lib/dev.js +126 -0
- package/dist/lib/dev.js.map +1 -0
- package/dist/lib/display-name.d.ts +5 -0
- package/dist/lib/display-name.d.ts.map +1 -0
- package/dist/lib/display-name.js +5 -0
- package/dist/lib/display-name.js.map +1 -0
- package/dist/lib/documentation.d.ts +5 -0
- package/dist/lib/documentation.d.ts.map +1 -0
- package/dist/lib/documentation.js +5 -0
- package/dist/lib/documentation.js.map +1 -0
- package/dist/lib/error-boundaries-astro.d.ts +6 -0
- package/dist/lib/error-boundaries-astro.d.ts.map +1 -0
- package/dist/lib/error-boundaries-astro.js +6 -0
- package/dist/lib/error-boundaries-astro.js.map +1 -0
- package/dist/lib/error-boundaries-react.d.ts +6 -0
- package/dist/lib/error-boundaries-react.d.ts.map +1 -0
- package/dist/lib/error-boundaries-react.js +6 -0
- package/dist/lib/error-boundaries-react.js.map +1 -0
- package/dist/lib/error-boundaries.d.ts +5 -0
- package/dist/lib/error-boundaries.d.ts.map +1 -0
- package/dist/lib/error-boundaries.js +5 -0
- package/dist/lib/error-boundaries.js.map +1 -0
- package/dist/lib/eslint-api.d.ts +13 -0
- package/dist/lib/eslint-api.d.ts.map +1 -0
- package/dist/lib/eslint-api.js +24 -0
- package/dist/lib/eslint-api.js.map +1 -0
- package/dist/lib/files.d.ts +5 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/files.js +5 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/formatting.d.ts +5 -0
- package/dist/lib/formatting.d.ts.map +1 -0
- package/dist/lib/formatting.js +5 -0
- package/dist/lib/formatting.js.map +1 -0
- package/dist/lib/github-report.d.ts +5 -0
- package/dist/lib/github-report.d.ts.map +1 -0
- package/dist/lib/github-report.js +5 -0
- package/dist/lib/github-report.js.map +1 -0
- package/dist/lib/history-report.d.ts +5 -0
- package/dist/lib/history-report.d.ts.map +1 -0
- package/dist/lib/history-report.js +5 -0
- package/dist/lib/history-report.js.map +1 -0
- package/dist/lib/imports.d.ts +5 -0
- package/dist/lib/imports.d.ts.map +1 -0
- package/dist/lib/imports.js +5 -0
- package/dist/lib/imports.js.map +1 -0
- package/dist/lib/index.d.ts +20 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +20 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/inline-if.d.ts +5 -0
- package/dist/lib/inline-if.d.ts.map +1 -0
- package/dist/lib/inline-if.js +5 -0
- package/dist/lib/inline-if.js.map +1 -0
- package/dist/lib/language-checks.d.ts +5 -0
- package/dist/lib/language-checks.d.ts.map +1 -0
- package/dist/lib/language-checks.js +5 -0
- package/dist/lib/language-checks.js.map +1 -0
- package/dist/lib/language-profiles.d.ts +5 -0
- package/dist/lib/language-profiles.d.ts.map +1 -0
- package/dist/lib/language-profiles.js +5 -0
- package/dist/lib/language-profiles.js.map +1 -0
- package/dist/lib/naming.d.ts +5 -0
- package/dist/lib/naming.d.ts.map +1 -0
- package/dist/lib/naming.js +5 -0
- package/dist/lib/naming.js.map +1 -0
- package/dist/lib/node-reporter.d.ts +6 -0
- package/dist/lib/node-reporter.d.ts.map +1 -0
- package/dist/lib/node-reporter.js +6 -0
- package/dist/lib/node-reporter.js.map +1 -0
- package/dist/lib/object-forwarding.d.ts +5 -0
- package/dist/lib/object-forwarding.d.ts.map +1 -0
- package/dist/lib/object-forwarding.js +5 -0
- package/dist/lib/object-forwarding.js.map +1 -0
- package/dist/lib/patterns.d.ts +5 -0
- package/dist/lib/patterns.d.ts.map +1 -0
- package/dist/lib/patterns.js +5 -0
- package/dist/lib/patterns.js.map +1 -0
- package/dist/lib/playwright-reporter.d.ts +6 -0
- package/dist/lib/playwright-reporter.d.ts.map +1 -0
- package/dist/lib/playwright-reporter.js +6 -0
- package/dist/lib/playwright-reporter.js.map +1 -0
- package/dist/lib/port.d.ts +21 -0
- package/dist/lib/port.d.ts.map +1 -0
- package/dist/lib/port.js +81 -0
- package/dist/lib/port.js.map +1 -0
- package/dist/lib/progress.d.ts +5 -0
- package/dist/lib/progress.d.ts.map +1 -0
- package/dist/lib/progress.js +5 -0
- package/dist/lib/progress.js.map +1 -0
- package/dist/lib/reports.d.ts +5 -0
- package/dist/lib/reports.d.ts.map +1 -0
- package/dist/lib/reports.js +5 -0
- package/dist/lib/reports.js.map +1 -0
- package/dist/lib/runner.d.ts +150 -0
- package/dist/lib/runner.d.ts.map +1 -0
- package/dist/lib/runner.js +4522 -0
- package/dist/lib/runner.js.map +1 -0
- package/dist/lib/security.d.ts +5 -0
- package/dist/lib/security.d.ts.map +1 -0
- package/dist/lib/security.js +5 -0
- package/dist/lib/security.js.map +1 -0
- package/dist/lib/single-use.d.ts +6 -0
- package/dist/lib/single-use.d.ts.map +1 -0
- package/dist/lib/single-use.js +5 -0
- package/dist/lib/single-use.js.map +1 -0
- package/dist/lib/source-kind.d.ts +5 -0
- package/dist/lib/source-kind.d.ts.map +1 -0
- package/dist/lib/source-kind.js +5 -0
- package/dist/lib/source-kind.js.map +1 -0
- package/dist/lib/spinner-worker.d.ts +6 -0
- package/dist/lib/spinner-worker.d.ts.map +1 -0
- package/dist/lib/spinner-worker.js +33 -0
- package/dist/lib/spinner-worker.js.map +1 -0
- package/dist/lib/ui-quality.d.ts +5 -0
- package/dist/lib/ui-quality.d.ts.map +1 -0
- package/dist/lib/ui-quality.js +5 -0
- package/dist/lib/ui-quality.js.map +1 -0
- package/dist/lib/ui-recommendations.d.ts +5 -0
- package/dist/lib/ui-recommendations.d.ts.map +1 -0
- package/dist/lib/ui-recommendations.js +5 -0
- package/dist/lib/ui-recommendations.js.map +1 -0
- package/dist/spinner-worker.d.ts +6 -0
- package/dist/spinner-worker.d.ts.map +1 -0
- package/dist/spinner-worker.js +39 -0
- package/dist/spinner-worker.js.map +1 -0
- package/package.json +160 -5
- package/quality-configs/checkstyle.xml +29 -0
- package/quality-configs/pmd-rules.xml +11 -0
- package/quality.schema.json +392 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/hygiene/src/capabilities/ui/lib/error-boundaries.ts
|
|
3
|
+
* Finds unguarded React application roots and safely wraps them by default.
|
|
4
|
+
*/
|
|
5
|
+
/*//////////////////////////////////////////////////
|
|
6
|
+
IMPORTS
|
|
7
|
+
//////////////////////////////////////////////////*/
|
|
8
|
+
// API
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { srcFiles } from '@terra-symposium/hygiene/core';
|
|
12
|
+
import { dirname, resolve } from 'node:path';
|
|
13
|
+
/*//////////////////////////////////////////////////
|
|
14
|
+
REGEX
|
|
15
|
+
//////////////////////////////////////////////////*/
|
|
16
|
+
const ERR_BOUNDAR_IU_REGEX = /error.?boundar/iu;
|
|
17
|
+
const ERR_BOUNDARY_IU_REGEX = /error.?boundary$/iu;
|
|
18
|
+
const BINTEGRATIONS_S_S_U_REGEX = /\bintegrations\s*:\s*\[/u;
|
|
19
|
+
const SRC_EXTS = new Set(['.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts']);
|
|
20
|
+
const FIXABLE_EXTS = new Set(['.js', '.jsx', '.mjs', '.ts', '.tsx', '.mts']);
|
|
21
|
+
const ASTRO_CONFIG = /^astro\.config\.(?:js|mjs|cjs|ts|mts|cts)$/u;
|
|
22
|
+
const IGNORED_CONFIG_DIRS = new Set(['.git', '.astro', '.next', '.nuxt', '.output', '.vercel', 'coverage', 'dist', 'node_modules', 'vendor']);
|
|
23
|
+
/*//////////////////////////////////////////////////
|
|
24
|
+
HELPERS
|
|
25
|
+
//////////////////////////////////////////////////*/
|
|
26
|
+
/**
|
|
27
|
+
* Returns the terminal name from a call or property-access expression.
|
|
28
|
+
*
|
|
29
|
+
* @param expr Expression whose final identifier is needed.
|
|
30
|
+
*
|
|
31
|
+
* @return The final identifier, or an empty string for other expressions.
|
|
32
|
+
*/
|
|
33
|
+
function exprName(expr) {
|
|
34
|
+
if (ts.isIdentifier(expr))
|
|
35
|
+
return expr.text;
|
|
36
|
+
if (ts.isPropertyAccessExpression(expr))
|
|
37
|
+
return expr.name.text;
|
|
38
|
+
if (ts.isCallExpression(expr))
|
|
39
|
+
return exprName(expr.expression);
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Removes TypeScript and parenthesized wrappers around an expression.
|
|
44
|
+
*
|
|
45
|
+
* @param expr Expression to unwrap.
|
|
46
|
+
*
|
|
47
|
+
* @return The underlying expression.
|
|
48
|
+
*/
|
|
49
|
+
function unwrap(expr) {
|
|
50
|
+
let current = expr;
|
|
51
|
+
while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isTypeAssertionExpression(current) || ts.isSatisfiesExpression(current) || ts.isNonNullExpression(current))
|
|
52
|
+
current = current.expression;
|
|
53
|
+
return current;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Collects local names that refer to an imported React error boundary.
|
|
57
|
+
*
|
|
58
|
+
* @param src Parsed source file.
|
|
59
|
+
*
|
|
60
|
+
* @return Local identifiers usable as an ErrorBoundary JSX tag.
|
|
61
|
+
*/
|
|
62
|
+
function importedBoundaries(src) {
|
|
63
|
+
const names = new Set();
|
|
64
|
+
for (const statement of src.statements) {
|
|
65
|
+
if (!ts.isImportDeclaration(statement) || !statement.importClause || !ts.isStringLiteral(statement.moduleSpecifier))
|
|
66
|
+
continue;
|
|
67
|
+
const clause = statement.importClause;
|
|
68
|
+
if (clause.name && ERR_BOUNDAR_IU_REGEX.test(statement.moduleSpecifier.text))
|
|
69
|
+
names.add(clause.name.text);
|
|
70
|
+
if (!clause.namedBindings || !ts.isNamedImports(clause.namedBindings))
|
|
71
|
+
continue;
|
|
72
|
+
for (const specifier of clause.namedBindings.elements) {
|
|
73
|
+
const orig = specifier.propertyName?.text ?? specifier.name.text;
|
|
74
|
+
if (ERR_BOUNDAR_IU_REGEX.test(orig) || (ERR_BOUNDAR_IU_REGEX.test(statement.moduleSpecifier.text) && orig === 'default'))
|
|
75
|
+
names.add(specifier.name.text);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return names;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Checks whether a JSX tag is an error-boundary component.
|
|
82
|
+
*
|
|
83
|
+
* @param tag JSX tag syntax.
|
|
84
|
+
* @param boundaries Imported boundary identifiers.
|
|
85
|
+
*
|
|
86
|
+
* @return True when the tag names a boundary component.
|
|
87
|
+
*/
|
|
88
|
+
function isBoundaryTag(tag, boundaries) {
|
|
89
|
+
if (ts.isIdentifier(tag))
|
|
90
|
+
return boundaries.has(tag.text) || ERR_BOUNDARY_IU_REGEX.test(tag.text);
|
|
91
|
+
return ts.isPropertyAccessExpression(tag) && ERR_BOUNDARY_IU_REGEX.test(tag.name.text);
|
|
92
|
+
}
|
|
93
|
+
// hygiene-ignore single-use -- Keep the documented isBoundaryReference declaration so its parameter and return contract remains attached.
|
|
94
|
+
/**
|
|
95
|
+
* Checks whether a JavaScript expression references a recognized boundary.
|
|
96
|
+
*
|
|
97
|
+
* @param expr Expression expected to name a boundary.
|
|
98
|
+
* @param boundaries Imported boundary identifiers.
|
|
99
|
+
*
|
|
100
|
+
* @return True when the expression names an error boundary.
|
|
101
|
+
*/
|
|
102
|
+
function isBoundaryRef(expr, boundaries) {
|
|
103
|
+
if (!expr)
|
|
104
|
+
return false;
|
|
105
|
+
const node = unwrap(expr);
|
|
106
|
+
if (ts.isIdentifier(node))
|
|
107
|
+
return boundaries.has(node.text) || ERR_BOUNDARY_IU_REGEX.test(node.text);
|
|
108
|
+
return ts.isPropertyAccessExpression(node) && ERR_BOUNDARY_IU_REGEX.test(node.name.text);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Checks whether a render expression is protected at its outermost JSX level.
|
|
112
|
+
*
|
|
113
|
+
* @param expr React root render expression.
|
|
114
|
+
* @param boundaries Imported boundary identifiers.
|
|
115
|
+
*
|
|
116
|
+
* @return True when the root expression is an error-boundary element.
|
|
117
|
+
*/
|
|
118
|
+
function isBoundaryExpr(expr, boundaries) {
|
|
119
|
+
const node = unwrap(expr);
|
|
120
|
+
if (ts.isJsxElement(node))
|
|
121
|
+
return isBoundaryTag(node.openingElement.tagName, boundaries);
|
|
122
|
+
if (ts.isJsxSelfClosingElement(node))
|
|
123
|
+
return isBoundaryTag(node.tagName, boundaries);
|
|
124
|
+
return ts.isCallExpression(node) && /createElement$/iu.test(exprName(node.expression)) && isBoundaryRef(node.arguments[0], boundaries);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Finds direct React root renders and records their mounted element arguments.
|
|
128
|
+
*
|
|
129
|
+
* @param src Parsed source file.
|
|
130
|
+
*
|
|
131
|
+
* @return Root render expressions with their argument positions.
|
|
132
|
+
*/
|
|
133
|
+
function reactRootRenders(src) {
|
|
134
|
+
const roots = new Set();
|
|
135
|
+
const sites = [];
|
|
136
|
+
const isFactory = (expr, name) => exprName(expr) === name;
|
|
137
|
+
const visit = (node) => {
|
|
138
|
+
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
|
|
139
|
+
const init = unwrap(node.initializer);
|
|
140
|
+
if (ts.isCallExpression(init) && isFactory(init.expression, 'createRoot'))
|
|
141
|
+
roots.add(node.name.text);
|
|
142
|
+
}
|
|
143
|
+
if (ts.isCallExpression(node)) {
|
|
144
|
+
if (isFactory(node.expression, 'hydrateRoot') && node.arguments.length > 1)
|
|
145
|
+
sites.push({ call: node, expression: node.arguments[1], index: 1 });
|
|
146
|
+
if (ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === 'render' && node.arguments.length > 0) {
|
|
147
|
+
const receiver = unwrap(node.expression.expression);
|
|
148
|
+
if (ts.isIdentifier(receiver) ? roots.has(receiver.text) : ts.isCallExpression(receiver) && isFactory(receiver.expression, 'createRoot'))
|
|
149
|
+
sites.push({ call: node, expression: node.arguments[0], index: 0 });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
ts.forEachChild(node, visit);
|
|
153
|
+
};
|
|
154
|
+
visit(src);
|
|
155
|
+
return sites;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Parses each configured JavaScript and TypeScript source file once for this check.
|
|
159
|
+
*
|
|
160
|
+
* @param cfg Quality configuration defining source roots and extensions.
|
|
161
|
+
*
|
|
162
|
+
* @return Parsed source files with root render sites.
|
|
163
|
+
*/
|
|
164
|
+
function srcInfos(cfg) {
|
|
165
|
+
return srcFiles(cfg)
|
|
166
|
+
.filter(f => SRC_EXTS.has(f.slice(f.lastIndexOf('.')).toLowerCase()))
|
|
167
|
+
.map(f => {
|
|
168
|
+
const text = readFileSync(f, 'utf8');
|
|
169
|
+
const ext = f.slice(f.lastIndexOf('.')).toLowerCase();
|
|
170
|
+
const src = ts.createSourceFile(f, text, ts.ScriptTarget.Latest, true, ext === '.tsx' || ext === '.jsx' ? ts.ScriptKind.TSX : /\.[cm]?ts$/iu.test(ext) ? ts.ScriptKind.TS : ts.ScriptKind.JS);
|
|
171
|
+
return { file: f, text, source: src, boundaries: importedBoundaries(src), renderSites: reactRootRenders(src) };
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Finds React root mounts whose top-level element does not use an error boundary.
|
|
176
|
+
*
|
|
177
|
+
* @param cfg Quality configuration defining source roots and extensions.
|
|
178
|
+
*
|
|
179
|
+
* @return Actionable findings for unguarded client-rendered app roots.
|
|
180
|
+
*/
|
|
181
|
+
export function errorBoundaryFindings(cfg) {
|
|
182
|
+
const findings = [];
|
|
183
|
+
for (const info of srcInfos(cfg)) {
|
|
184
|
+
for (const site of info.renderSites) {
|
|
185
|
+
if (isBoundaryExpr(site.expression, info.boundaries))
|
|
186
|
+
continue;
|
|
187
|
+
const point = info.source.getLineAndCharacterOfPosition(site.expression.getStart(info.source));
|
|
188
|
+
findings.push({
|
|
189
|
+
file: info.file,
|
|
190
|
+
line: point.line + 1,
|
|
191
|
+
column: point.character + 1,
|
|
192
|
+
message: 'React application roots must render inside an ErrorBoundary so component failures leave the rest of the page available.',
|
|
193
|
+
fixable: FIXABLE_EXTS.has(info.file.slice(info.file.lastIndexOf('.')).toLowerCase()),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
for (const file of astroConfigFiles(cfg.root)) {
|
|
198
|
+
if (hasAstroBoundaryIntegration(readFileSync(file, 'utf8')))
|
|
199
|
+
continue;
|
|
200
|
+
const integration = astroIntegrationSpecifier(file, cfg.root);
|
|
201
|
+
findings.push({
|
|
202
|
+
file,
|
|
203
|
+
line: 1,
|
|
204
|
+
column: 1,
|
|
205
|
+
message: integration
|
|
206
|
+
? 'Astro configs must install the shared hydration error-boundary integration so failed islands leave the rest of the page available.'
|
|
207
|
+
: 'Declare and install a shared error-boundary package that exports the Astro integration before adding it to this config.',
|
|
208
|
+
fixable: Boolean(integration),
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return findings;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Wraps unguarded JSX React roots and adds the shared boundary import when needed.
|
|
215
|
+
*
|
|
216
|
+
* @param cfg Quality configuration defining source roots and extensions.
|
|
217
|
+
*
|
|
218
|
+
* @return Number of source files updated.
|
|
219
|
+
*/
|
|
220
|
+
export function fixErrorBoundaries(cfg) {
|
|
221
|
+
let fixedFiles = fixAstroBoundaryIntegrations(cfg.root);
|
|
222
|
+
for (const info of srcInfos(cfg)) {
|
|
223
|
+
const unguarded = info.renderSites.filter(s => !isBoundaryExpr(s.expression, info.boundaries));
|
|
224
|
+
if (!unguarded.length || !FIXABLE_EXTS.has(info.file.slice(info.file.lastIndexOf('.')).toLowerCase()))
|
|
225
|
+
continue;
|
|
226
|
+
const ext = info.file.slice(info.file.lastIndexOf('.')).toLowerCase();
|
|
227
|
+
const supportsJsx = ext === '.jsx' || ext === '.tsx';
|
|
228
|
+
const identifiers = new Set();
|
|
229
|
+
const collectIdentifiers = (node) => {
|
|
230
|
+
if (ts.isIdentifier(node))
|
|
231
|
+
identifiers.add(node.text);
|
|
232
|
+
ts.forEachChild(node, collectIdentifiers);
|
|
233
|
+
};
|
|
234
|
+
collectIdentifiers(info.source);
|
|
235
|
+
const uniqueName = (base) => {
|
|
236
|
+
let candidate = base;
|
|
237
|
+
let suffix = 2;
|
|
238
|
+
while (identifiers.has(candidate))
|
|
239
|
+
candidate = `${base}${suffix++}`;
|
|
240
|
+
identifiers.add(candidate);
|
|
241
|
+
return candidate;
|
|
242
|
+
};
|
|
243
|
+
const needsBoundaryImport = info.boundaries.size === 0;
|
|
244
|
+
const boundaryName = info.boundaries.values().next().value ?? uniqueName('TerraRootErrorBoundary');
|
|
245
|
+
const createElName = supportsJsx ? '' : uniqueName('terraCreateElement');
|
|
246
|
+
const edits = unguarded.map(s => ({
|
|
247
|
+
start: s.expression.getStart(info.source),
|
|
248
|
+
end: s.expression.getEnd(),
|
|
249
|
+
text: supportsJsx
|
|
250
|
+
? `<${boundaryName} name="Application root">${info.text.slice(s.expression.getStart(info.source), s.expression.getEnd())}</${boundaryName}>`
|
|
251
|
+
: `${createElName}(${boundaryName}, { name: 'Application root' }, (${info.text.slice(s.expression.getStart(info.source), s.expression.getEnd())}))`,
|
|
252
|
+
}));
|
|
253
|
+
if (needsBoundaryImport || !supportsJsx) {
|
|
254
|
+
const insertion = info.source.statements.filter(s => ts.isImportDeclaration(s) || (ts.isExpressionStatement(s) && ts.isStringLiteral(s.expression))).at(-1)?.end ?? 0;
|
|
255
|
+
edits.push({
|
|
256
|
+
start: insertion,
|
|
257
|
+
end: insertion,
|
|
258
|
+
text: `${insertion ? '\n' : ''}${[
|
|
259
|
+
...(needsBoundaryImport ? [`import { ErrorBoundary as ${boundaryName} } from '${'@terra-symposium/boundaries/react'}';`] : []),
|
|
260
|
+
...(!supportsJsx ? [`import { createElement as ${createElName} } from 'react';`] : []),
|
|
261
|
+
].join('\n')}\n`,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
let text = info.text;
|
|
265
|
+
for (const edit of edits.sort((l, r) => r.start - l.start))
|
|
266
|
+
text = `${text.slice(0, edit.start)}${edit.text}${text.slice(edit.end)}`;
|
|
267
|
+
writeFileSync(info.file, text);
|
|
268
|
+
fixedFiles += 1;
|
|
269
|
+
}
|
|
270
|
+
return fixedFiles;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Finds local Astro configuration files while excluding dependency and build trees.
|
|
274
|
+
*
|
|
275
|
+
* @param root Repository root to inspect.
|
|
276
|
+
*
|
|
277
|
+
* @return Repository-owned Astro config paths.
|
|
278
|
+
*/
|
|
279
|
+
function astroConfigFiles(root) {
|
|
280
|
+
const found = [];
|
|
281
|
+
const visit = (dir, depth) => {
|
|
282
|
+
let entries;
|
|
283
|
+
try {
|
|
284
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
for (const entry of entries) {
|
|
290
|
+
const path = `${dir}/${entry.name}`;
|
|
291
|
+
if (entry.isFile() && ASTRO_CONFIG.test(entry.name))
|
|
292
|
+
found.push(path);
|
|
293
|
+
else if (entry.isDirectory() && depth < 4 && !IGNORED_CONFIG_DIRS.has(entry.name))
|
|
294
|
+
visit(path, depth + 1);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
visit(root, 0);
|
|
298
|
+
return found.sort();
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Detects the shared Astro boundary integration import and invocation.
|
|
302
|
+
*
|
|
303
|
+
* @param text Astro config source.
|
|
304
|
+
*
|
|
305
|
+
* @return True when the integration is installed in the config.
|
|
306
|
+
*/
|
|
307
|
+
function hasAstroBoundaryIntegration(text) {
|
|
308
|
+
const imported = text.match(/import\s*\{\s*terraErrorBoundaryIntegration(?:\s+as\s+(\w+))?\s*\}\s*from\s*['"]@terra-symposium\/(?:boundaries|hygiene)\/astro-integration['"]/u);
|
|
309
|
+
if (!imported)
|
|
310
|
+
return false;
|
|
311
|
+
return new RegExp(`\\b${imported[1] ?? 'terraErrorBoundaryIntegration'}\\s*\\(`, 'u').test(text);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Selects an installed Astro integration exported by the package owning the config.
|
|
315
|
+
*
|
|
316
|
+
* @param configFile Astro config whose nearest package manifest owns dependencies.
|
|
317
|
+
* @param root Repository boundary for manifest and node_modules discovery.
|
|
318
|
+
*
|
|
319
|
+
* @return Import specifier when the declared dependency exports an installed entry.
|
|
320
|
+
*/
|
|
321
|
+
function astroIntegrationSpecifier(configFile, root) {
|
|
322
|
+
let packageRoot = dirname(configFile);
|
|
323
|
+
let packageJson;
|
|
324
|
+
while (packageRoot === root || packageRoot.startsWith(`${root}/`)) {
|
|
325
|
+
const manifestPath = resolve(packageRoot, 'package.json');
|
|
326
|
+
if (existsSync(manifestPath)) {
|
|
327
|
+
try {
|
|
328
|
+
packageJson = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (packageRoot === root)
|
|
336
|
+
break;
|
|
337
|
+
packageRoot = dirname(packageRoot);
|
|
338
|
+
}
|
|
339
|
+
if (!packageJson)
|
|
340
|
+
return;
|
|
341
|
+
const dependencies = [packageJson.dependencies, packageJson.devDependencies, packageJson.peerDependencies].filter((value) => !!value && typeof value === 'object');
|
|
342
|
+
for (const name of ['@terra-symposium/boundaries', '@terra-symposium/hygiene']) {
|
|
343
|
+
if (!dependencies.some(group => typeof group[name] === 'string'))
|
|
344
|
+
continue;
|
|
345
|
+
const parts = name.split('/');
|
|
346
|
+
let installedPath;
|
|
347
|
+
for (let dir = packageRoot; dir === root || dir.startsWith(`${root}/`); dir = dirname(dir)) {
|
|
348
|
+
const candidate = resolve(dir, 'node_modules', ...parts, 'package.json');
|
|
349
|
+
if (existsSync(candidate)) {
|
|
350
|
+
installedPath = dirname(candidate);
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
if (dir === root)
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
if (!installedPath)
|
|
357
|
+
continue;
|
|
358
|
+
try {
|
|
359
|
+
const exportEntry = JSON.parse(readFileSync(resolve(installedPath, 'package.json'), 'utf8')).exports?.['./astro-integration'];
|
|
360
|
+
const target = typeof exportEntry === 'string' ? exportEntry : undefined;
|
|
361
|
+
if (target && existsSync(resolve(installedPath, target)))
|
|
362
|
+
return `${name}/astro-integration`;
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// hygiene-ignore single-use -- Keep the documented fixAstroBoundaryIntegrations declaration so its parameter and return contract remains attached.
|
|
370
|
+
/**
|
|
371
|
+
* Adds the shared Astro integration to every local config that does not have it.
|
|
372
|
+
*
|
|
373
|
+
* @param root Repository root to update.
|
|
374
|
+
*
|
|
375
|
+
* @return Number of Astro config files updated.
|
|
376
|
+
*/
|
|
377
|
+
function fixAstroBoundaryIntegrations(root) {
|
|
378
|
+
let fixed = 0;
|
|
379
|
+
for (const file of astroConfigFiles(root)) {
|
|
380
|
+
let text = readFileSync(file, 'utf8');
|
|
381
|
+
if (hasAstroBoundaryIntegration(text))
|
|
382
|
+
continue;
|
|
383
|
+
const specifier = astroIntegrationSpecifier(file, root);
|
|
384
|
+
if (!specifier)
|
|
385
|
+
continue;
|
|
386
|
+
const alias = '__terraErrorBoundaryIntegration';
|
|
387
|
+
if (BINTEGRATIONS_S_S_U_REGEX.test(text))
|
|
388
|
+
text = text.replace(BINTEGRATIONS_S_S_U_REGEX, m => `${m}${alias}(), `);
|
|
389
|
+
else {
|
|
390
|
+
const objectStart = /(?:defineConfig\s*\(\s*|export\s+default\s*)\{/u;
|
|
391
|
+
if (!objectStart.test(text))
|
|
392
|
+
continue;
|
|
393
|
+
text = text.replace(objectStart, m => `${m}\n\tintegrations: [${alias}()],`);
|
|
394
|
+
}
|
|
395
|
+
text = `import { terraErrorBoundaryIntegration as ${alias} } from '${specifier}';\n${text}`;
|
|
396
|
+
writeFileSync(file, text);
|
|
397
|
+
fixed += 1;
|
|
398
|
+
}
|
|
399
|
+
return fixed;
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=error-boundaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundaries.js","sourceRoot":"","sources":["../../../../src/capabilities/ui/lib/error-boundaries.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;oDAEoD;AAEpD,MAAM;AACN,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAK7C;;oDAEoD;AAEpD,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACnD,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAM7D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACzF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7E,MAAM,YAAY,GAAG,6CAA6C,CAAC;AACnE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EA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C;AACF,CAAC;AAED,mJAAmJ;AACnJ;;;;;;GAMG;AACH,SAAS,4BAA4B,CAAC,IAAY;IACjD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,IAAI,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,IAAI,2BAA2B,CAAC,IAAI,CAAC;YAAE,SAAS;QAChD,MAAM,SAAS,GAAG,yBAAyB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,SAAS;YAAE,SAAS;QACzB,MAAM,KAAK,GAAG,iCAAiC,CAAC;QAChD,IAAI,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;aAC7G,CAAC;YACL,MAAM,WAAW,GAAG,iDAAiD,CAAC;YACtE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,SAAS;YACtC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,sBAAsB,KAAK,MAAM,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,GAAG,6CAA6C,KAAK,YAAY,SAAS,OAAO,IAAI,EAAE,CAAC;QAC5F,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC1B,KAAK,IAAI,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/hygiene/src/capabilities/ui/lib/ui-recommendations.ts
|
|
3
|
+
* On-demand recommendations for native UI elements with shared component equivalents.
|
|
4
|
+
*/
|
|
5
|
+
import type { QualityCfg } from '@terra-symposium/hygiene/core';
|
|
6
|
+
/** One configured native JSX element and its suggested shared component. */
|
|
7
|
+
export type UiRecommendationRule = {
|
|
8
|
+
element: string;
|
|
9
|
+
component: string;
|
|
10
|
+
import: string;
|
|
11
|
+
variant?: string;
|
|
12
|
+
types?: string[];
|
|
13
|
+
when?: 'always' | 'button-like' | 'text-link';
|
|
14
|
+
reason?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Source scope and native-element mappings for the on-demand recommendation pass. */
|
|
17
|
+
export type UiRecommendationSettings = {
|
|
18
|
+
rules?: UiRecommendationRule[];
|
|
19
|
+
extensions?: string[];
|
|
20
|
+
ignoredFiles?: string[];
|
|
21
|
+
ignoredDirectories?: string[];
|
|
22
|
+
};
|
|
23
|
+
/** A source location and the shared component that may replace its native JSX element. */
|
|
24
|
+
export type UiComponentRecommendation = {
|
|
25
|
+
file: string;
|
|
26
|
+
line: number;
|
|
27
|
+
column: number;
|
|
28
|
+
element: string;
|
|
29
|
+
component: string;
|
|
30
|
+
import: string;
|
|
31
|
+
variant?: string;
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Finds UI elements that have a configured or conventional shared-component equivalent.
|
|
36
|
+
*
|
|
37
|
+
* The scan reports quality errors on demand and does not alter files or run in normal full-quality checks.
|
|
38
|
+
* Astro, JSX, and TSX are parsed so comments, text, and already-shared components are not reported.
|
|
39
|
+
*
|
|
40
|
+
* @param cfg Repository quality configuration and optional UI recommendation policy.
|
|
41
|
+
*
|
|
42
|
+
* @return Sorted native-element recommendations with source positions and import guidance.
|
|
43
|
+
*/
|
|
44
|
+
export declare function uiComponentRecommendations(cfg: QualityCfg): UiComponentRecommendation[];
|
|
45
|
+
//# sourceMappingURL=ui-recommendations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-recommendations.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/ui/lib/ui-recommendations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAQhE,4EAA4E;AAC5E,MAAM,MAAM,oBAAoB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,GAAG,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9L,sFAAsF;AACtF,MAAM,MAAM,wBAAwB,GAAG;IAAE,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEzJ,0FAA0F;AAC1F,MAAM,MAAM,yBAAyB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA8F7K;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,UAAU,GAAG,yBAAyB,EAAE,CAyEvF"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/hygiene/src/capabilities/ui/lib/ui-recommendations.ts
|
|
3
|
+
* On-demand recommendations for native UI elements with shared component equivalents.
|
|
4
|
+
*/
|
|
5
|
+
/*//////////////////////////////////////////////////
|
|
6
|
+
IMPORTS
|
|
7
|
+
//////////////////////////////////////////////////*/
|
|
8
|
+
// API
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
import { displayPath, srcFiles } from '@terra-symposium/hygiene/core';
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
/*//////////////////////////////////////////////////
|
|
13
|
+
REGEX
|
|
14
|
+
//////////////////////////////////////////////////*/
|
|
15
|
+
const S_U_REGEX = /\s+/u;
|
|
16
|
+
// hygiene-ignore single-use -- Reuse this module-level rule array across scans rather than allocating it on each invocation.
|
|
17
|
+
const DEFAULT_RULES = [
|
|
18
|
+
{ element: 'button', component: 'Button', import: '@/components/ui/button', reason: 'Use the shared button primitive to keep action variants and interaction states consistent.' },
|
|
19
|
+
{
|
|
20
|
+
element: 'input',
|
|
21
|
+
component: 'Input',
|
|
22
|
+
import: '@/components/ui/input',
|
|
23
|
+
types: ['date', 'datetime-local', 'email', 'file', 'month', 'number', 'password', 'search', 'tel', 'text', 'time', 'url', 'week'],
|
|
24
|
+
reason: 'Use the shared input primitive to keep control sizing, focus, and validation states consistent.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
element: 'input',
|
|
28
|
+
component: 'Button',
|
|
29
|
+
import: '@/components/ui/button',
|
|
30
|
+
types: ['button', 'reset', 'submit'],
|
|
31
|
+
reason: 'Use the shared button primitive for this input-based action while preserving its type.',
|
|
32
|
+
},
|
|
33
|
+
{ element: 'a', component: 'ButtonLink', import: '@/components/ui/button', when: 'button-like', reason: 'This action-styled link can use ButtonLink while retaining anchor navigation semantics.' },
|
|
34
|
+
{ element: 'a', component: 'ButtonLink', import: '@/components/ui/button', when: 'text-link', reason: 'This styled text link can use ButtonLink while retaining anchor navigation semantics.' },
|
|
35
|
+
];
|
|
36
|
+
// hygiene-ignore single-use -- Reuse this module-level extension array across scans rather than allocating it on each invocation.
|
|
37
|
+
const DEFAULT_EXTS = ['.astro', '.jsx', '.tsx'];
|
|
38
|
+
/*//////////////////////////////////////////////////
|
|
39
|
+
HELPERS
|
|
40
|
+
//////////////////////////////////////////////////*/
|
|
41
|
+
/**
|
|
42
|
+
* Reads a literal JSX attribute value without evaluating runtime expressions.
|
|
43
|
+
*
|
|
44
|
+
* @param attr JSX attribute to inspect.
|
|
45
|
+
*
|
|
46
|
+
* @return Static string value, or undefined when the value is dynamic or absent.
|
|
47
|
+
*/
|
|
48
|
+
function staticAttrValue(attr) {
|
|
49
|
+
const init = attr?.initializer;
|
|
50
|
+
if (!init)
|
|
51
|
+
return attr ? '' : undefined;
|
|
52
|
+
if (ts.isStringLiteral(init) || ts.isNoSubstitutionTemplateLiteral(init))
|
|
53
|
+
return init.text;
|
|
54
|
+
if (!ts.isJsxExpression(init) || !init.expression)
|
|
55
|
+
return undefined;
|
|
56
|
+
let expr = init.expression;
|
|
57
|
+
while (ts.isParenthesizedExpression(expr))
|
|
58
|
+
expr = expr.expression;
|
|
59
|
+
return ts.isStringLiteral(expr) || ts.isNoSubstitutionTemplateLiteral(expr) ? expr.text : undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns one JSX attribute by its exact lower-case name.
|
|
63
|
+
*
|
|
64
|
+
* @param el JSX opening element to inspect.
|
|
65
|
+
* @param name Attribute name to find.
|
|
66
|
+
*
|
|
67
|
+
* @return Matching attribute when present.
|
|
68
|
+
*/
|
|
69
|
+
function jsxAttr(el, name) {
|
|
70
|
+
return el.attributes.properties.find((p) => ts.isJsxAttribute(p) && ts.isIdentifier(p.name) && p.name.text === name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the shared text-link variant represented by static anchor classes.
|
|
74
|
+
*
|
|
75
|
+
* @param value Static class attribute value.
|
|
76
|
+
*
|
|
77
|
+
* @return The matching ButtonLink underline variant for recognized text-link styling.
|
|
78
|
+
*/
|
|
79
|
+
function textLinkVariant(value) {
|
|
80
|
+
const classes = new Set((value ?? '').split(S_U_REGEX).filter(Boolean));
|
|
81
|
+
const color = classes.has('text-primary')
|
|
82
|
+
? 'primary'
|
|
83
|
+
: classes.has('text-secondary-foreground')
|
|
84
|
+
? 'secondary'
|
|
85
|
+
: classes.has('text-destructive')
|
|
86
|
+
? 'destructive'
|
|
87
|
+
: classes.has('text-foreground')
|
|
88
|
+
? 'gray'
|
|
89
|
+
: undefined;
|
|
90
|
+
if (!color || (!classes.has('underline') && !classes.has('hover:underline')))
|
|
91
|
+
return undefined;
|
|
92
|
+
return `${color}-underline`;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reads static classes from JSX/TSX or Astro's `class` attribute.
|
|
96
|
+
*
|
|
97
|
+
* @param el JSX opening element to inspect.
|
|
98
|
+
*
|
|
99
|
+
* @return Static class string when available.
|
|
100
|
+
*/
|
|
101
|
+
function staticClasses(el) {
|
|
102
|
+
return staticAttrValue(jsxAttr(el, 'className')) ?? staticAttrValue(jsxAttr(el, 'class'));
|
|
103
|
+
}
|
|
104
|
+
/*//////////////////////////////////////////////////
|
|
105
|
+
RECOMMENDATIONS
|
|
106
|
+
//////////////////////////////////////////////////*/
|
|
107
|
+
/**
|
|
108
|
+
* Finds UI elements that have a configured or conventional shared-component equivalent.
|
|
109
|
+
*
|
|
110
|
+
* The scan reports quality errors on demand and does not alter files or run in normal full-quality checks.
|
|
111
|
+
* Astro, JSX, and TSX are parsed so comments, text, and already-shared components are not reported.
|
|
112
|
+
*
|
|
113
|
+
* @param cfg Repository quality configuration and optional UI recommendation policy.
|
|
114
|
+
*
|
|
115
|
+
* @return Sorted native-element recommendations with source positions and import guidance.
|
|
116
|
+
*/
|
|
117
|
+
export function uiComponentRecommendations(cfg) {
|
|
118
|
+
const settings = cfg.uiRecommendations;
|
|
119
|
+
const rules = settings?.rules ?? DEFAULT_RULES;
|
|
120
|
+
const exts = settings?.extensions ?? DEFAULT_EXTS;
|
|
121
|
+
const ignoredFiles = new Set((settings?.ignoredFiles ?? []).map(f => f.replaceAll('\\', '/')));
|
|
122
|
+
const findings = [];
|
|
123
|
+
for (const file of srcFiles({ ...cfg, extensions: exts })) {
|
|
124
|
+
const relativeFile = displayPath(cfg, file).replaceAll('\\', '/');
|
|
125
|
+
if ((function isIgnoredFile(file, ignoredDirs, ignoredFiles) {
|
|
126
|
+
const norm = file.replaceAll('\\', '/');
|
|
127
|
+
const segments = norm.split('/');
|
|
128
|
+
return (segments.some((s, i) => s === 'components' && segments[i + 1] === 'ui') ||
|
|
129
|
+
ignoredFiles.has(norm) ||
|
|
130
|
+
ignoredDirs.some(d => {
|
|
131
|
+
const prefix = d.replaceAll('\\', '/').replace(/^\/+|\/+$/gu, '');
|
|
132
|
+
return prefix && (norm === prefix || norm.startsWith(`${prefix}/`));
|
|
133
|
+
}));
|
|
134
|
+
})(relativeFile, settings?.ignoredDirectories ?? [], ignoredFiles))
|
|
135
|
+
continue;
|
|
136
|
+
const parsed = ts.createSourceFile(file, readFileSync(file, 'utf8'), ts.ScriptTarget.Latest, true, file.endsWith('.jsx') ? ts.ScriptKind.JSX : ts.ScriptKind.TSX);
|
|
137
|
+
const visit = (node) => {
|
|
138
|
+
if ((ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && ts.isIdentifier(node.tagName)) {
|
|
139
|
+
const el = node.tagName.text;
|
|
140
|
+
if (el === el.toLowerCase()) {
|
|
141
|
+
const rule = rules.find(c => c.element === el &&
|
|
142
|
+
(function ruleMatches(rule, el) {
|
|
143
|
+
const type = jsxAttr(el, 'type');
|
|
144
|
+
if (rule.types) {
|
|
145
|
+
const typeValue = type ? staticAttrValue(type) : 'text';
|
|
146
|
+
if (typeValue === undefined || !rule.types.includes(typeValue.toLowerCase()))
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (rule.when === 'button-like')
|
|
150
|
+
return (function isButtonLike(value) {
|
|
151
|
+
const classes = new Set((value ?? '').split(S_U_REGEX).filter(Boolean));
|
|
152
|
+
return ([...classes].some(c => /^px-/u.test(c)) &&
|
|
153
|
+
[...classes].some(c => /^py-/u.test(c)) &&
|
|
154
|
+
[...classes].some(c => c === 'border' || c === 'inline-flex' || c === 'flex' || c.startsWith('rounded')) &&
|
|
155
|
+
[...classes].some(c => c === 'font-medium' || c === 'no-underline' || c.startsWith('bg-')));
|
|
156
|
+
})(staticClasses(el));
|
|
157
|
+
if (rule.when === 'text-link')
|
|
158
|
+
return Boolean(textLinkVariant(staticClasses(el)));
|
|
159
|
+
return true;
|
|
160
|
+
})(c, node));
|
|
161
|
+
if (rule) {
|
|
162
|
+
const { line, character } = parsed.getLineAndCharacterOfPosition(node.getStart(parsed));
|
|
163
|
+
const variant = rule.variant ?? (el === 'a' && rule.when === 'text-link' ? textLinkVariant(staticClasses(node)) : undefined);
|
|
164
|
+
findings.push({
|
|
165
|
+
file: relativeFile,
|
|
166
|
+
line: line + 1,
|
|
167
|
+
column: character + 1,
|
|
168
|
+
element: el,
|
|
169
|
+
component: rule.component,
|
|
170
|
+
import: rule.import,
|
|
171
|
+
...(variant ? { variant } : {}),
|
|
172
|
+
reason: rule.reason ?? `Review whether this native <${el}> should use the shared ${rule.component} component.`,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
ts.forEachChild(node, visit);
|
|
178
|
+
};
|
|
179
|
+
visit(parsed);
|
|
180
|
+
}
|
|
181
|
+
return findings.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column);
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=ui-recommendations.js.map
|