driftdetect-detectors 0.1.0
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/accessibility/alt-text.d.ts +63 -0
- package/dist/accessibility/alt-text.d.ts.map +1 -0
- package/dist/accessibility/alt-text.js +100 -0
- package/dist/accessibility/alt-text.js.map +1 -0
- package/dist/accessibility/aria-roles.d.ts +65 -0
- package/dist/accessibility/aria-roles.d.ts.map +1 -0
- package/dist/accessibility/aria-roles.js +87 -0
- package/dist/accessibility/aria-roles.js.map +1 -0
- package/dist/accessibility/focus-management.d.ts +62 -0
- package/dist/accessibility/focus-management.d.ts.map +1 -0
- package/dist/accessibility/focus-management.js +88 -0
- package/dist/accessibility/focus-management.js.map +1 -0
- package/dist/accessibility/heading-hierarchy.d.ts +66 -0
- package/dist/accessibility/heading-hierarchy.d.ts.map +1 -0
- package/dist/accessibility/heading-hierarchy.js +94 -0
- package/dist/accessibility/heading-hierarchy.js.map +1 -0
- package/dist/accessibility/index.d.ts +25 -0
- package/dist/accessibility/index.d.ts.map +1 -0
- package/dist/accessibility/index.js +21 -0
- package/dist/accessibility/index.js.map +1 -0
- package/dist/accessibility/keyboard-nav.d.ts +63 -0
- package/dist/accessibility/keyboard-nav.d.ts.map +1 -0
- package/dist/accessibility/keyboard-nav.js +86 -0
- package/dist/accessibility/keyboard-nav.js.map +1 -0
- package/dist/accessibility/semantic-html.d.ts +76 -0
- package/dist/accessibility/semantic-html.d.ts.map +1 -0
- package/dist/accessibility/semantic-html.js +204 -0
- package/dist/accessibility/semantic-html.js.map +1 -0
- package/dist/api/client-patterns.d.ts +121 -0
- package/dist/api/client-patterns.d.ts.map +1 -0
- package/dist/api/client-patterns.js +478 -0
- package/dist/api/client-patterns.js.map +1 -0
- package/dist/api/error-format.d.ts +140 -0
- package/dist/api/error-format.d.ts.map +1 -0
- package/dist/api/error-format.js +614 -0
- package/dist/api/error-format.js.map +1 -0
- package/dist/api/http-methods.d.ts +255 -0
- package/dist/api/http-methods.d.ts.map +1 -0
- package/dist/api/http-methods.js +890 -0
- package/dist/api/http-methods.js.map +1 -0
- package/dist/api/index.d.ts +16 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +37 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/pagination.d.ts +133 -0
- package/dist/api/pagination.d.ts.map +1 -0
- package/dist/api/pagination.js +521 -0
- package/dist/api/pagination.js.map +1 -0
- package/dist/api/response-envelope.d.ts +261 -0
- package/dist/api/response-envelope.d.ts.map +1 -0
- package/dist/api/response-envelope.js +1050 -0
- package/dist/api/response-envelope.js.map +1 -0
- package/dist/api/retry-patterns.d.ts +117 -0
- package/dist/api/retry-patterns.d.ts.map +1 -0
- package/dist/api/retry-patterns.js +480 -0
- package/dist/api/retry-patterns.js.map +1 -0
- package/dist/api/route-structure.d.ts +128 -0
- package/dist/api/route-structure.d.ts.map +1 -0
- package/dist/api/route-structure.js +738 -0
- package/dist/api/route-structure.js.map +1 -0
- package/dist/auth/audit-logging.d.ts +80 -0
- package/dist/auth/audit-logging.d.ts.map +1 -0
- package/dist/auth/audit-logging.js +370 -0
- package/dist/auth/audit-logging.js.map +1 -0
- package/dist/auth/index.d.ts +33 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +49 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware-usage.d.ts +65 -0
- package/dist/auth/middleware-usage.d.ts.map +1 -0
- package/dist/auth/middleware-usage.js +192 -0
- package/dist/auth/middleware-usage.js.map +1 -0
- package/dist/auth/permission-checks.d.ts +60 -0
- package/dist/auth/permission-checks.d.ts.map +1 -0
- package/dist/auth/permission-checks.js +159 -0
- package/dist/auth/permission-checks.js.map +1 -0
- package/dist/auth/rbac-patterns.d.ts +68 -0
- package/dist/auth/rbac-patterns.d.ts.map +1 -0
- package/dist/auth/rbac-patterns.js +143 -0
- package/dist/auth/rbac-patterns.js.map +1 -0
- package/dist/auth/resource-ownership.d.ts +77 -0
- package/dist/auth/resource-ownership.d.ts.map +1 -0
- package/dist/auth/resource-ownership.js +324 -0
- package/dist/auth/resource-ownership.js.map +1 -0
- package/dist/auth/token-handling.d.ts +64 -0
- package/dist/auth/token-handling.d.ts.map +1 -0
- package/dist/auth/token-handling.js +151 -0
- package/dist/auth/token-handling.js.map +1 -0
- package/dist/base/ast-detector.d.ts +421 -0
- package/dist/base/ast-detector.d.ts.map +1 -0
- package/dist/base/ast-detector.js +699 -0
- package/dist/base/ast-detector.js.map +1 -0
- package/dist/base/base-detector.d.ts +366 -0
- package/dist/base/base-detector.d.ts.map +1 -0
- package/dist/base/base-detector.js +170 -0
- package/dist/base/base-detector.js.map +1 -0
- package/dist/base/index.d.ts +12 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +17 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/regex-detector.d.ts +421 -0
- package/dist/base/regex-detector.d.ts.map +1 -0
- package/dist/base/regex-detector.js +537 -0
- package/dist/base/regex-detector.js.map +1 -0
- package/dist/base/structural-detector.d.ts +424 -0
- package/dist/base/structural-detector.d.ts.map +1 -0
- package/dist/base/structural-detector.js +731 -0
- package/dist/base/structural-detector.js.map +1 -0
- package/dist/base/types.d.ts +53 -0
- package/dist/base/types.d.ts.map +1 -0
- package/dist/base/types.js +5 -0
- package/dist/base/types.js.map +1 -0
- package/dist/components/component-structure.d.ts +163 -0
- package/dist/components/component-structure.d.ts.map +1 -0
- package/dist/components/component-structure.js +500 -0
- package/dist/components/component-structure.js.map +1 -0
- package/dist/components/composition.d.ts +287 -0
- package/dist/components/composition.d.ts.map +1 -0
- package/dist/components/composition.js +1123 -0
- package/dist/components/composition.js.map +1 -0
- package/dist/components/duplicate-detection.d.ts +251 -0
- package/dist/components/duplicate-detection.d.ts.map +1 -0
- package/dist/components/duplicate-detection.js +804 -0
- package/dist/components/duplicate-detection.js.map +1 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +51 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/near-duplicate.d.ts +402 -0
- package/dist/components/near-duplicate.d.ts.map +1 -0
- package/dist/components/near-duplicate.js +1090 -0
- package/dist/components/near-duplicate.js.map +1 -0
- package/dist/components/props-patterns.d.ts +194 -0
- package/dist/components/props-patterns.d.ts.map +1 -0
- package/dist/components/props-patterns.js +795 -0
- package/dist/components/props-patterns.js.map +1 -0
- package/dist/components/ref-forwarding.d.ts +250 -0
- package/dist/components/ref-forwarding.d.ts.map +1 -0
- package/dist/components/ref-forwarding.js +832 -0
- package/dist/components/ref-forwarding.js.map +1 -0
- package/dist/components/state-patterns.d.ts +291 -0
- package/dist/components/state-patterns.d.ts.map +1 -0
- package/dist/components/state-patterns.js +970 -0
- package/dist/components/state-patterns.js.map +1 -0
- package/dist/config/config-validation.d.ts +74 -0
- package/dist/config/config-validation.d.ts.map +1 -0
- package/dist/config/config-validation.js +446 -0
- package/dist/config/config-validation.js.map +1 -0
- package/dist/config/default-values.d.ts +72 -0
- package/dist/config/default-values.d.ts.map +1 -0
- package/dist/config/default-values.js +386 -0
- package/dist/config/default-values.js.map +1 -0
- package/dist/config/env-naming.d.ts +73 -0
- package/dist/config/env-naming.d.ts.map +1 -0
- package/dist/config/env-naming.js +429 -0
- package/dist/config/env-naming.js.map +1 -0
- package/dist/config/environment-detection.d.ts +72 -0
- package/dist/config/environment-detection.d.ts.map +1 -0
- package/dist/config/environment-detection.js +400 -0
- package/dist/config/environment-detection.js.map +1 -0
- package/dist/config/feature-flags.d.ts +72 -0
- package/dist/config/feature-flags.d.ts.map +1 -0
- package/dist/config/feature-flags.js +384 -0
- package/dist/config/feature-flags.js.map +1 -0
- package/dist/config/index.d.ts +27 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +43 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/required-optional.d.ts +71 -0
- package/dist/config/required-optional.d.ts.map +1 -0
- package/dist/config/required-optional.js +344 -0
- package/dist/config/required-optional.js.map +1 -0
- package/dist/data-access/connection-pooling.d.ts +63 -0
- package/dist/data-access/connection-pooling.d.ts.map +1 -0
- package/dist/data-access/connection-pooling.js +297 -0
- package/dist/data-access/connection-pooling.js.map +1 -0
- package/dist/data-access/dto-patterns.d.ts +64 -0
- package/dist/data-access/dto-patterns.d.ts.map +1 -0
- package/dist/data-access/dto-patterns.js +291 -0
- package/dist/data-access/dto-patterns.js.map +1 -0
- package/dist/data-access/index.d.ts +31 -0
- package/dist/data-access/index.d.ts.map +1 -0
- package/dist/data-access/index.js +49 -0
- package/dist/data-access/index.js.map +1 -0
- package/dist/data-access/n-plus-one.d.ts +60 -0
- package/dist/data-access/n-plus-one.d.ts.map +1 -0
- package/dist/data-access/n-plus-one.js +264 -0
- package/dist/data-access/n-plus-one.js.map +1 -0
- package/dist/data-access/query-patterns.d.ts +64 -0
- package/dist/data-access/query-patterns.d.ts.map +1 -0
- package/dist/data-access/query-patterns.js +314 -0
- package/dist/data-access/query-patterns.js.map +1 -0
- package/dist/data-access/repository-pattern.d.ts +62 -0
- package/dist/data-access/repository-pattern.d.ts.map +1 -0
- package/dist/data-access/repository-pattern.js +257 -0
- package/dist/data-access/repository-pattern.js.map +1 -0
- package/dist/data-access/transaction-patterns.d.ts +61 -0
- package/dist/data-access/transaction-patterns.d.ts.map +1 -0
- package/dist/data-access/transaction-patterns.js +277 -0
- package/dist/data-access/transaction-patterns.js.map +1 -0
- package/dist/data-access/validation-patterns.d.ts +62 -0
- package/dist/data-access/validation-patterns.d.ts.map +1 -0
- package/dist/data-access/validation-patterns.js +301 -0
- package/dist/data-access/validation-patterns.js.map +1 -0
- package/dist/documentation/deprecation.d.ts +62 -0
- package/dist/documentation/deprecation.d.ts.map +1 -0
- package/dist/documentation/deprecation.js +83 -0
- package/dist/documentation/deprecation.js.map +1 -0
- package/dist/documentation/example-code.d.ts +64 -0
- package/dist/documentation/example-code.d.ts.map +1 -0
- package/dist/documentation/example-code.js +79 -0
- package/dist/documentation/example-code.js.map +1 -0
- package/dist/documentation/index.d.ts +22 -0
- package/dist/documentation/index.d.ts.map +1 -0
- package/dist/documentation/index.js +19 -0
- package/dist/documentation/index.js.map +1 -0
- package/dist/documentation/jsdoc-patterns.d.ts +72 -0
- package/dist/documentation/jsdoc-patterns.d.ts.map +1 -0
- package/dist/documentation/jsdoc-patterns.js +92 -0
- package/dist/documentation/jsdoc-patterns.js.map +1 -0
- package/dist/documentation/readme-structure.d.ts +67 -0
- package/dist/documentation/readme-structure.d.ts.map +1 -0
- package/dist/documentation/readme-structure.js +76 -0
- package/dist/documentation/readme-structure.js.map +1 -0
- package/dist/documentation/todo-patterns.d.ts +67 -0
- package/dist/documentation/todo-patterns.d.ts.map +1 -0
- package/dist/documentation/todo-patterns.js +73 -0
- package/dist/documentation/todo-patterns.js.map +1 -0
- package/dist/errors/async-errors.d.ts +72 -0
- package/dist/errors/async-errors.d.ts.map +1 -0
- package/dist/errors/async-errors.js +214 -0
- package/dist/errors/async-errors.js.map +1 -0
- package/dist/errors/circuit-breaker.d.ts +53 -0
- package/dist/errors/circuit-breaker.d.ts.map +1 -0
- package/dist/errors/circuit-breaker.js +241 -0
- package/dist/errors/circuit-breaker.js.map +1 -0
- package/dist/errors/error-codes.d.ts +73 -0
- package/dist/errors/error-codes.d.ts.map +1 -0
- package/dist/errors/error-codes.js +211 -0
- package/dist/errors/error-codes.js.map +1 -0
- package/dist/errors/error-logging.d.ts +73 -0
- package/dist/errors/error-logging.d.ts.map +1 -0
- package/dist/errors/error-logging.js +256 -0
- package/dist/errors/error-logging.js.map +1 -0
- package/dist/errors/error-propagation.d.ts +73 -0
- package/dist/errors/error-propagation.d.ts.map +1 -0
- package/dist/errors/error-propagation.js +244 -0
- package/dist/errors/error-propagation.js.map +1 -0
- package/dist/errors/exception-hierarchy.d.ts +75 -0
- package/dist/errors/exception-hierarchy.d.ts.map +1 -0
- package/dist/errors/exception-hierarchy.js +259 -0
- package/dist/errors/exception-hierarchy.js.map +1 -0
- package/dist/errors/index.d.ts +31 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +49 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/try-catch-placement.d.ts +73 -0
- package/dist/errors/try-catch-placement.d.ts.map +1 -0
- package/dist/errors/try-catch-placement.js +214 -0
- package/dist/errors/try-catch-placement.js.map +1 -0
- package/dist/index.d.ts +221 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +245 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/context-fields.d.ts +48 -0
- package/dist/logging/context-fields.d.ts.map +1 -0
- package/dist/logging/context-fields.js +160 -0
- package/dist/logging/context-fields.js.map +1 -0
- package/dist/logging/correlation-ids.d.ts +44 -0
- package/dist/logging/correlation-ids.d.ts.map +1 -0
- package/dist/logging/correlation-ids.js +144 -0
- package/dist/logging/correlation-ids.js.map +1 -0
- package/dist/logging/health-checks.d.ts +45 -0
- package/dist/logging/health-checks.d.ts.map +1 -0
- package/dist/logging/health-checks.js +165 -0
- package/dist/logging/health-checks.js.map +1 -0
- package/dist/logging/index.d.ts +31 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +49 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/log-levels.d.ts +46 -0
- package/dist/logging/log-levels.d.ts.map +1 -0
- package/dist/logging/log-levels.js +178 -0
- package/dist/logging/log-levels.js.map +1 -0
- package/dist/logging/metric-naming.d.ts +46 -0
- package/dist/logging/metric-naming.d.ts.map +1 -0
- package/dist/logging/metric-naming.js +157 -0
- package/dist/logging/metric-naming.js.map +1 -0
- package/dist/logging/pii-redaction.d.ts +44 -0
- package/dist/logging/pii-redaction.d.ts.map +1 -0
- package/dist/logging/pii-redaction.js +166 -0
- package/dist/logging/pii-redaction.js.map +1 -0
- package/dist/logging/structured-format.d.ts +53 -0
- package/dist/logging/structured-format.d.ts.map +1 -0
- package/dist/logging/structured-format.js +235 -0
- package/dist/logging/structured-format.js.map +1 -0
- package/dist/performance/bundle-size.d.ts +79 -0
- package/dist/performance/bundle-size.d.ts.map +1 -0
- package/dist/performance/bundle-size.js +276 -0
- package/dist/performance/bundle-size.js.map +1 -0
- package/dist/performance/caching-patterns.d.ts +78 -0
- package/dist/performance/caching-patterns.d.ts.map +1 -0
- package/dist/performance/caching-patterns.js +257 -0
- package/dist/performance/caching-patterns.js.map +1 -0
- package/dist/performance/code-splitting.d.ts +86 -0
- package/dist/performance/code-splitting.d.ts.map +1 -0
- package/dist/performance/code-splitting.js +447 -0
- package/dist/performance/code-splitting.js.map +1 -0
- package/dist/performance/debounce-throttle.d.ts +75 -0
- package/dist/performance/debounce-throttle.d.ts.map +1 -0
- package/dist/performance/debounce-throttle.js +232 -0
- package/dist/performance/debounce-throttle.js.map +1 -0
- package/dist/performance/index.d.ts +28 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/index.js +39 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/performance/lazy-loading.d.ts +75 -0
- package/dist/performance/lazy-loading.d.ts.map +1 -0
- package/dist/performance/lazy-loading.js +233 -0
- package/dist/performance/lazy-loading.js.map +1 -0
- package/dist/performance/memoization.d.ts +75 -0
- package/dist/performance/memoization.d.ts.map +1 -0
- package/dist/performance/memoization.js +251 -0
- package/dist/performance/memoization.js.map +1 -0
- package/dist/registry/detector-registry.d.ts +266 -0
- package/dist/registry/detector-registry.d.ts.map +1 -0
- package/dist/registry/detector-registry.js +526 -0
- package/dist/registry/detector-registry.js.map +1 -0
- package/dist/registry/index.d.ts +10 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +10 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/loader.d.ts +232 -0
- package/dist/registry/loader.d.ts.map +1 -0
- package/dist/registry/loader.js +419 -0
- package/dist/registry/loader.js.map +1 -0
- package/dist/registry/types.d.ts +111 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +19 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/security/csp-headers.d.ts +78 -0
- package/dist/security/csp-headers.d.ts.map +1 -0
- package/dist/security/csp-headers.js +401 -0
- package/dist/security/csp-headers.js.map +1 -0
- package/dist/security/csrf-protection.d.ts +72 -0
- package/dist/security/csrf-protection.d.ts.map +1 -0
- package/dist/security/csrf-protection.js +344 -0
- package/dist/security/csrf-protection.js.map +1 -0
- package/dist/security/index.d.ts +30 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +48 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/input-sanitization.d.ts +74 -0
- package/dist/security/input-sanitization.d.ts.map +1 -0
- package/dist/security/input-sanitization.js +373 -0
- package/dist/security/input-sanitization.js.map +1 -0
- package/dist/security/rate-limiting.d.ts +81 -0
- package/dist/security/rate-limiting.d.ts.map +1 -0
- package/dist/security/rate-limiting.js +535 -0
- package/dist/security/rate-limiting.js.map +1 -0
- package/dist/security/secret-management.d.ts +83 -0
- package/dist/security/secret-management.d.ts.map +1 -0
- package/dist/security/secret-management.js +547 -0
- package/dist/security/secret-management.js.map +1 -0
- package/dist/security/sql-injection.d.ts +76 -0
- package/dist/security/sql-injection.d.ts.map +1 -0
- package/dist/security/sql-injection.js +383 -0
- package/dist/security/sql-injection.js.map +1 -0
- package/dist/security/xss-prevention.d.ts +80 -0
- package/dist/security/xss-prevention.d.ts.map +1 -0
- package/dist/security/xss-prevention.js +416 -0
- package/dist/security/xss-prevention.js.map +1 -0
- package/dist/structural/barrel-exports.d.ts +178 -0
- package/dist/structural/barrel-exports.d.ts.map +1 -0
- package/dist/structural/barrel-exports.js +553 -0
- package/dist/structural/barrel-exports.js.map +1 -0
- package/dist/structural/circular-deps.d.ts +140 -0
- package/dist/structural/circular-deps.d.ts.map +1 -0
- package/dist/structural/circular-deps.js +422 -0
- package/dist/structural/circular-deps.js.map +1 -0
- package/dist/structural/co-location.d.ts +202 -0
- package/dist/structural/co-location.d.ts.map +1 -0
- package/dist/structural/co-location.js +640 -0
- package/dist/structural/co-location.js.map +1 -0
- package/dist/structural/directory-structure.d.ts +151 -0
- package/dist/structural/directory-structure.d.ts.map +1 -0
- package/dist/structural/directory-structure.js +457 -0
- package/dist/structural/directory-structure.js.map +1 -0
- package/dist/structural/file-naming.d.ts +61 -0
- package/dist/structural/file-naming.d.ts.map +1 -0
- package/dist/structural/file-naming.js +231 -0
- package/dist/structural/file-naming.js.map +1 -0
- package/dist/structural/import-ordering.d.ts +212 -0
- package/dist/structural/import-ordering.d.ts.map +1 -0
- package/dist/structural/import-ordering.js +821 -0
- package/dist/structural/import-ordering.js.map +1 -0
- package/dist/structural/index.d.ts +23 -0
- package/dist/structural/index.d.ts.map +1 -0
- package/dist/structural/index.js +26 -0
- package/dist/structural/index.js.map +1 -0
- package/dist/structural/module-boundaries.d.ts +164 -0
- package/dist/structural/module-boundaries.d.ts.map +1 -0
- package/dist/structural/module-boundaries.js +616 -0
- package/dist/structural/module-boundaries.js.map +1 -0
- package/dist/structural/package-boundaries.d.ts +182 -0
- package/dist/structural/package-boundaries.d.ts.map +1 -0
- package/dist/structural/package-boundaries.js +602 -0
- package/dist/structural/package-boundaries.js.map +1 -0
- package/dist/styling/class-naming.d.ts +263 -0
- package/dist/styling/class-naming.d.ts.map +1 -0
- package/dist/styling/class-naming.js +892 -0
- package/dist/styling/class-naming.js.map +1 -0
- package/dist/styling/color-usage.d.ts +213 -0
- package/dist/styling/color-usage.d.ts.map +1 -0
- package/dist/styling/color-usage.js +732 -0
- package/dist/styling/color-usage.js.map +1 -0
- package/dist/styling/design-tokens.d.ts +212 -0
- package/dist/styling/design-tokens.d.ts.map +1 -0
- package/dist/styling/design-tokens.js +748 -0
- package/dist/styling/design-tokens.js.map +1 -0
- package/dist/styling/index.d.ts +16 -0
- package/dist/styling/index.d.ts.map +1 -0
- package/dist/styling/index.js +56 -0
- package/dist/styling/index.js.map +1 -0
- package/dist/styling/responsive.d.ts +304 -0
- package/dist/styling/responsive.d.ts.map +1 -0
- package/dist/styling/responsive.js +888 -0
- package/dist/styling/responsive.js.map +1 -0
- package/dist/styling/spacing-scale.d.ts +248 -0
- package/dist/styling/spacing-scale.d.ts.map +1 -0
- package/dist/styling/spacing-scale.js +865 -0
- package/dist/styling/spacing-scale.js.map +1 -0
- package/dist/styling/tailwind-patterns.d.ts +305 -0
- package/dist/styling/tailwind-patterns.d.ts.map +1 -0
- package/dist/styling/tailwind-patterns.js +1181 -0
- package/dist/styling/tailwind-patterns.js.map +1 -0
- package/dist/styling/typography.d.ts +281 -0
- package/dist/styling/typography.d.ts.map +1 -0
- package/dist/styling/typography.js +1004 -0
- package/dist/styling/typography.js.map +1 -0
- package/dist/styling/z-index-scale.d.ts +270 -0
- package/dist/styling/z-index-scale.d.ts.map +1 -0
- package/dist/styling/z-index-scale.js +714 -0
- package/dist/styling/z-index-scale.js.map +1 -0
- package/dist/testing/co-location.d.ts +42 -0
- package/dist/testing/co-location.d.ts.map +1 -0
- package/dist/testing/co-location.js +134 -0
- package/dist/testing/co-location.js.map +1 -0
- package/dist/testing/describe-naming.d.ts +47 -0
- package/dist/testing/describe-naming.d.ts.map +1 -0
- package/dist/testing/describe-naming.js +150 -0
- package/dist/testing/describe-naming.js.map +1 -0
- package/dist/testing/file-naming.d.ts +44 -0
- package/dist/testing/file-naming.d.ts.map +1 -0
- package/dist/testing/file-naming.js +131 -0
- package/dist/testing/file-naming.js.map +1 -0
- package/dist/testing/fixture-patterns.d.ts +52 -0
- package/dist/testing/fixture-patterns.d.ts.map +1 -0
- package/dist/testing/fixture-patterns.js +228 -0
- package/dist/testing/fixture-patterns.js.map +1 -0
- package/dist/testing/index.d.ts +31 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +49 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-patterns.d.ts +53 -0
- package/dist/testing/mock-patterns.d.ts.map +1 -0
- package/dist/testing/mock-patterns.js +264 -0
- package/dist/testing/mock-patterns.js.map +1 -0
- package/dist/testing/setup-teardown.d.ts +55 -0
- package/dist/testing/setup-teardown.d.ts.map +1 -0
- package/dist/testing/setup-teardown.js +262 -0
- package/dist/testing/setup-teardown.js.map +1 -0
- package/dist/testing/test-structure.d.ts +51 -0
- package/dist/testing/test-structure.d.ts.map +1 -0
- package/dist/testing/test-structure.js +225 -0
- package/dist/testing/test-structure.js.map +1 -0
- package/dist/types/any-usage.d.ts +99 -0
- package/dist/types/any-usage.d.ts.map +1 -0
- package/dist/types/any-usage.js +641 -0
- package/dist/types/any-usage.js.map +1 -0
- package/dist/types/file-location.d.ts +76 -0
- package/dist/types/file-location.d.ts.map +1 -0
- package/dist/types/file-location.js +395 -0
- package/dist/types/file-location.js.map +1 -0
- package/dist/types/generic-patterns.d.ts +97 -0
- package/dist/types/generic-patterns.d.ts.map +1 -0
- package/dist/types/generic-patterns.js +615 -0
- package/dist/types/generic-patterns.js.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +43 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/interface-vs-type.d.ts +81 -0
- package/dist/types/interface-vs-type.d.ts.map +1 -0
- package/dist/types/interface-vs-type.js +440 -0
- package/dist/types/interface-vs-type.js.map +1 -0
- package/dist/types/naming-conventions.d.ts +84 -0
- package/dist/types/naming-conventions.d.ts.map +1 -0
- package/dist/types/naming-conventions.js +455 -0
- package/dist/types/naming-conventions.js.map +1 -0
- package/dist/types/type-assertions.d.ts +98 -0
- package/dist/types/type-assertions.d.ts.map +1 -0
- package/dist/types/type-assertions.js +639 -0
- package/dist/types/type-assertions.js.map +1 -0
- package/dist/types/utility-types.d.ts +110 -0
- package/dist/types/utility-types.d.ts.map +1 -0
- package/dist/types/utility-types.js +547 -0
- package/dist/types/utility-types.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Types Detector - TypeScript utility type pattern detection
|
|
3
|
+
*
|
|
4
|
+
* Detects utility type patterns including:
|
|
5
|
+
* - Built-in utility types (Partial, Required, Pick, Omit, etc.)
|
|
6
|
+
* - Custom utility types
|
|
7
|
+
* - Mapped type utilities
|
|
8
|
+
* - Conditional type utilities
|
|
9
|
+
* - Template literal types
|
|
10
|
+
* - Recursive types
|
|
11
|
+
*
|
|
12
|
+
* @requirements 18.5 - Utility type patterns
|
|
13
|
+
*/
|
|
14
|
+
import type { Violation, QuickFix, PatternCategory, Language } from 'driftdetect-core';
|
|
15
|
+
import { RegexDetector } from '../base/regex-detector.js';
|
|
16
|
+
import type { DetectionContext, DetectionResult } from '../base/base-detector.js';
|
|
17
|
+
export type UtilityTypePatternType = 'partial' | 'required' | 'readonly' | 'pick' | 'omit' | 'record' | 'exclude' | 'extract' | 'non-nullable' | 'return-type' | 'parameters' | 'instance-type' | 'awaited' | 'this-type' | 'custom-mapped' | 'custom-conditional' | 'template-literal' | 'recursive-type' | 'branded-type' | 'deep-partial' | 'deep-readonly';
|
|
18
|
+
export type UtilityTypeViolationType = 'redundant-utility' | 'nested-utility' | 'missing-utility' | 'complex-utility-chain';
|
|
19
|
+
export interface UtilityTypePatternInfo {
|
|
20
|
+
type: UtilityTypePatternType;
|
|
21
|
+
file: string;
|
|
22
|
+
line: number;
|
|
23
|
+
column: number;
|
|
24
|
+
matchedText: string;
|
|
25
|
+
utilityName?: string | undefined;
|
|
26
|
+
targetType?: string | undefined;
|
|
27
|
+
isBuiltIn: boolean;
|
|
28
|
+
context?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface UtilityTypeViolationInfo {
|
|
31
|
+
type: UtilityTypeViolationType;
|
|
32
|
+
file: string;
|
|
33
|
+
line: number;
|
|
34
|
+
column: number;
|
|
35
|
+
matchedText: string;
|
|
36
|
+
issue: string;
|
|
37
|
+
suggestedFix?: string | undefined;
|
|
38
|
+
severity: 'high' | 'medium' | 'low';
|
|
39
|
+
}
|
|
40
|
+
export interface UtilityTypesAnalysis {
|
|
41
|
+
patterns: UtilityTypePatternInfo[];
|
|
42
|
+
violations: UtilityTypeViolationInfo[];
|
|
43
|
+
builtInCount: number;
|
|
44
|
+
customCount: number;
|
|
45
|
+
usesDeepUtilities: boolean;
|
|
46
|
+
usesBrandedTypes: boolean;
|
|
47
|
+
confidence: number;
|
|
48
|
+
}
|
|
49
|
+
export declare const PARTIAL_PATTERNS: readonly [RegExp, RegExp];
|
|
50
|
+
export declare const REQUIRED_PATTERNS: readonly [RegExp, RegExp];
|
|
51
|
+
export declare const READONLY_PATTERNS: readonly [RegExp, RegExp, RegExp];
|
|
52
|
+
export declare const PICK_PATTERNS: readonly [RegExp, RegExp];
|
|
53
|
+
export declare const OMIT_PATTERNS: readonly [RegExp, RegExp];
|
|
54
|
+
export declare const RECORD_PATTERNS: readonly [RegExp, RegExp, RegExp];
|
|
55
|
+
export declare const EXCLUDE_PATTERNS: readonly [RegExp, RegExp];
|
|
56
|
+
export declare const EXTRACT_PATTERNS: readonly [RegExp];
|
|
57
|
+
export declare const NON_NULLABLE_PATTERNS: readonly [RegExp];
|
|
58
|
+
export declare const RETURN_TYPE_PATTERNS: readonly [RegExp, RegExp];
|
|
59
|
+
export declare const PARAMETERS_PATTERNS: readonly [RegExp, RegExp];
|
|
60
|
+
export declare const INSTANCE_TYPE_PATTERNS: readonly [RegExp, RegExp];
|
|
61
|
+
export declare const AWAITED_PATTERNS: readonly [RegExp, RegExp, RegExp];
|
|
62
|
+
export declare const THIS_TYPE_PATTERNS: readonly [RegExp, RegExp, RegExp];
|
|
63
|
+
export declare const CUSTOM_MAPPED_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp];
|
|
64
|
+
export declare const CUSTOM_CONDITIONAL_PATTERNS: readonly [RegExp, RegExp];
|
|
65
|
+
export declare const TEMPLATE_LITERAL_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
66
|
+
export declare const RECURSIVE_TYPE_PATTERNS: readonly [RegExp, RegExp];
|
|
67
|
+
export declare const BRANDED_TYPE_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp];
|
|
68
|
+
export declare const DEEP_PARTIAL_PATTERNS: readonly [RegExp, RegExp];
|
|
69
|
+
export declare const DEEP_READONLY_PATTERNS: readonly [RegExp, RegExp];
|
|
70
|
+
export declare const REDUNDANT_UTILITY_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp];
|
|
71
|
+
export declare const NESTED_UTILITY_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp];
|
|
72
|
+
export declare const COMPLEX_UTILITY_CHAIN_PATTERNS: readonly [RegExp];
|
|
73
|
+
export declare function shouldExcludeFile(filePath: string): boolean;
|
|
74
|
+
export declare function detectPartial(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
75
|
+
export declare function detectRequired(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
76
|
+
export declare function detectReadonly(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
77
|
+
export declare function detectPick(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
78
|
+
export declare function detectOmit(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
79
|
+
export declare function detectRecord(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
80
|
+
export declare function detectExclude(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
81
|
+
export declare function detectExtract(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
82
|
+
export declare function detectNonNullable(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
83
|
+
export declare function detectReturnType(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
84
|
+
export declare function detectParameters(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
85
|
+
export declare function detectInstanceType(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
86
|
+
export declare function detectAwaited(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
87
|
+
export declare function detectThisType(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
88
|
+
export declare function detectCustomMapped(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
89
|
+
export declare function detectCustomConditional(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
90
|
+
export declare function detectTemplateLiteral(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
91
|
+
export declare function detectRecursiveType(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
92
|
+
export declare function detectBrandedType(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
93
|
+
export declare function detectDeepPartial(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
94
|
+
export declare function detectDeepReadonly(content: string, filePath: string): UtilityTypePatternInfo[];
|
|
95
|
+
export declare function detectRedundantUtilityViolations(content: string, filePath: string): UtilityTypeViolationInfo[];
|
|
96
|
+
export declare function detectNestedUtilityViolations(content: string, filePath: string): UtilityTypeViolationInfo[];
|
|
97
|
+
export declare function detectComplexUtilityChainViolations(content: string, filePath: string): UtilityTypeViolationInfo[];
|
|
98
|
+
export declare function analyzeUtilityTypes(content: string, filePath: string): UtilityTypesAnalysis;
|
|
99
|
+
export declare class UtilityTypesDetector extends RegexDetector {
|
|
100
|
+
readonly id = "types/utility-types";
|
|
101
|
+
readonly name = "Utility Types Detector";
|
|
102
|
+
readonly description = "Detects TypeScript utility type patterns including built-in and custom utilities";
|
|
103
|
+
readonly category: PatternCategory;
|
|
104
|
+
readonly subcategory = "utility-types";
|
|
105
|
+
readonly supportedLanguages: Language[];
|
|
106
|
+
detect(context: DetectionContext): Promise<DetectionResult>;
|
|
107
|
+
generateQuickFix(_violation: Violation): QuickFix | null;
|
|
108
|
+
}
|
|
109
|
+
export declare function createUtilityTypesDetector(): UtilityTypesDetector;
|
|
110
|
+
//# sourceMappingURL=utility-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility-types.d.ts","sourceRoot":"","sources":["../../src/types/utility-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EA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,aAAa;IACrD,QAAQ,CAAC,EAAE,yBAAyB;IACpC,QAAQ,CAAC,IAAI,4BAA4B;IACzC,QAAQ,CAAC,WAAW,sFACiE;IACrF,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAW;IAC7C,QAAQ,CAAC,WAAW,mBAAmB;IACvC,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,EAAE,CAAkB;IAEnD,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAuBjE,gBAAgB,CAAC,UAAU,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI;CAGzD;AAED,wBAAgB,0BAA0B,IAAI,oBAAoB,CAEjE"}
|
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Types Detector - TypeScript utility type pattern detection
|
|
3
|
+
*
|
|
4
|
+
* Detects utility type patterns including:
|
|
5
|
+
* - Built-in utility types (Partial, Required, Pick, Omit, etc.)
|
|
6
|
+
* - Custom utility types
|
|
7
|
+
* - Mapped type utilities
|
|
8
|
+
* - Conditional type utilities
|
|
9
|
+
* - Template literal types
|
|
10
|
+
* - Recursive types
|
|
11
|
+
*
|
|
12
|
+
* @requirements 18.5 - Utility type patterns
|
|
13
|
+
*/
|
|
14
|
+
import { RegexDetector } from '../base/regex-detector.js';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Constants
|
|
17
|
+
// ============================================================================
|
|
18
|
+
export const PARTIAL_PATTERNS = [
|
|
19
|
+
/Partial<(\w+)>/g,
|
|
20
|
+
/Partial<typeof\s+\w+>/g,
|
|
21
|
+
];
|
|
22
|
+
export const REQUIRED_PATTERNS = [
|
|
23
|
+
/Required<(\w+)>/g,
|
|
24
|
+
/Required<typeof\s+\w+>/g,
|
|
25
|
+
];
|
|
26
|
+
export const READONLY_PATTERNS = [
|
|
27
|
+
/Readonly<(\w+)>/g,
|
|
28
|
+
/Readonly<typeof\s+\w+>/g,
|
|
29
|
+
/readonly\s+\w+\[\]/g,
|
|
30
|
+
];
|
|
31
|
+
export const PICK_PATTERNS = [
|
|
32
|
+
/Pick<(\w+),\s*['"`]?\w+['"`]?(?:\s*\|\s*['"`]?\w+['"`]?)*>/g,
|
|
33
|
+
/Pick<(\w+),\s*keyof\s+\w+>/g,
|
|
34
|
+
];
|
|
35
|
+
export const OMIT_PATTERNS = [
|
|
36
|
+
/Omit<(\w+),\s*['"`]?\w+['"`]?(?:\s*\|\s*['"`]?\w+['"`]?)*>/g,
|
|
37
|
+
/Omit<(\w+),\s*keyof\s+\w+>/g,
|
|
38
|
+
];
|
|
39
|
+
export const RECORD_PATTERNS = [
|
|
40
|
+
/Record<(\w+),\s*(\w+)>/g,
|
|
41
|
+
/Record<string,\s*(\w+)>/g,
|
|
42
|
+
/Record<number,\s*(\w+)>/g,
|
|
43
|
+
];
|
|
44
|
+
export const EXCLUDE_PATTERNS = [
|
|
45
|
+
/Exclude<(\w+),\s*(\w+)>/g,
|
|
46
|
+
/Exclude<(\w+),\s*null\s*\|\s*undefined>/g,
|
|
47
|
+
];
|
|
48
|
+
export const EXTRACT_PATTERNS = [
|
|
49
|
+
/Extract<(\w+),\s*(\w+)>/g,
|
|
50
|
+
];
|
|
51
|
+
export const NON_NULLABLE_PATTERNS = [
|
|
52
|
+
/NonNullable<(\w+)>/g,
|
|
53
|
+
];
|
|
54
|
+
export const RETURN_TYPE_PATTERNS = [
|
|
55
|
+
/ReturnType<typeof\s+(\w+)>/g,
|
|
56
|
+
/ReturnType<(\w+)>/g,
|
|
57
|
+
];
|
|
58
|
+
export const PARAMETERS_PATTERNS = [
|
|
59
|
+
/Parameters<typeof\s+(\w+)>/g,
|
|
60
|
+
/Parameters<(\w+)>/g,
|
|
61
|
+
];
|
|
62
|
+
export const INSTANCE_TYPE_PATTERNS = [
|
|
63
|
+
/InstanceType<typeof\s+(\w+)>/g,
|
|
64
|
+
/InstanceType<(\w+)>/g,
|
|
65
|
+
];
|
|
66
|
+
export const AWAITED_PATTERNS = [
|
|
67
|
+
/Awaited<(\w+)>/g,
|
|
68
|
+
/Awaited<Promise<(\w+)>>/g,
|
|
69
|
+
/Awaited<ReturnType<typeof\s+\w+>>/g,
|
|
70
|
+
];
|
|
71
|
+
export const THIS_TYPE_PATTERNS = [
|
|
72
|
+
/ThisType<(\w+)>/g,
|
|
73
|
+
/ThisParameterType<(\w+)>/g,
|
|
74
|
+
/OmitThisParameter<(\w+)>/g,
|
|
75
|
+
];
|
|
76
|
+
export const CUSTOM_MAPPED_PATTERNS = [
|
|
77
|
+
/type\s+(\w+)\s*<[^>]+>\s*=\s*\{\s*\[/g,
|
|
78
|
+
/type\s+(\w+)\s*=\s*\{\s*\[\s*\w+\s+in/g,
|
|
79
|
+
/\{\s*\[\s*\w+\s+in\s+keyof\s+\w+\s*\]\s*-?\s*\??\s*:/g,
|
|
80
|
+
/\{\s*-?\s*readonly\s*\[\s*\w+\s+in/g,
|
|
81
|
+
];
|
|
82
|
+
export const CUSTOM_CONDITIONAL_PATTERNS = [
|
|
83
|
+
/type\s+(\w+)\s*<[^>]+>\s*=\s*\w+\s+extends\s+\w+\s*\?/g,
|
|
84
|
+
/type\s+(\w+)\s*=\s*\w+\s+extends\s+infer\s+\w+\s*\?/g,
|
|
85
|
+
];
|
|
86
|
+
export const TEMPLATE_LITERAL_PATTERNS = [
|
|
87
|
+
/type\s+(\w+)\s*=\s*`\$\{[^}]+\}`/g,
|
|
88
|
+
/`\$\{[^}]+\}\$\{[^}]+\}`/g,
|
|
89
|
+
/Uppercase<(\w+)>/g,
|
|
90
|
+
/Lowercase<(\w+)>/g,
|
|
91
|
+
/Capitalize<(\w+)>/g,
|
|
92
|
+
/Uncapitalize<(\w+)>/g,
|
|
93
|
+
];
|
|
94
|
+
export const RECURSIVE_TYPE_PATTERNS = [
|
|
95
|
+
/type\s+(\w+)\s*=\s*[^;]*\1[^;]*;/g,
|
|
96
|
+
/type\s+(\w+)\s*<[^>]+>\s*=\s*[^;]*\1</g,
|
|
97
|
+
];
|
|
98
|
+
export const BRANDED_TYPE_PATTERNS = [
|
|
99
|
+
/type\s+(\w+)\s*=\s*\w+\s*&\s*\{\s*(?:readonly\s+)?__brand\s*:/g,
|
|
100
|
+
/type\s+(\w+)\s*=\s*\w+\s*&\s*\{\s*(?:readonly\s+)?_tag\s*:/g,
|
|
101
|
+
/type\s+(\w+)\s*=\s*\w+\s*&\s*\{\s*(?:readonly\s+)?__type\s*:/g,
|
|
102
|
+
/declare\s+const\s+\w+:\s*unique\s+symbol/g,
|
|
103
|
+
];
|
|
104
|
+
export const DEEP_PARTIAL_PATTERNS = [
|
|
105
|
+
/type\s+DeepPartial\s*</g,
|
|
106
|
+
/DeepPartial<(\w+)>/g,
|
|
107
|
+
];
|
|
108
|
+
export const DEEP_READONLY_PATTERNS = [
|
|
109
|
+
/type\s+DeepReadonly\s*</g,
|
|
110
|
+
/DeepReadonly<(\w+)>/g,
|
|
111
|
+
];
|
|
112
|
+
export const REDUNDANT_UTILITY_PATTERNS = [
|
|
113
|
+
/Partial<Partial<(\w+)>>/g,
|
|
114
|
+
/Required<Required<(\w+)>>/g,
|
|
115
|
+
/Readonly<Readonly<(\w+)>>/g,
|
|
116
|
+
/NonNullable<NonNullable<(\w+)>>/g,
|
|
117
|
+
];
|
|
118
|
+
export const NESTED_UTILITY_PATTERNS = [
|
|
119
|
+
/Partial<Required<(\w+)>>/g,
|
|
120
|
+
/Required<Partial<(\w+)>>/g,
|
|
121
|
+
/Pick<Omit<(\w+)/g,
|
|
122
|
+
/Omit<Pick<(\w+)/g,
|
|
123
|
+
];
|
|
124
|
+
export const COMPLEX_UTILITY_CHAIN_PATTERNS = [
|
|
125
|
+
/\w+<\w+<\w+<\w+<\w+/g, // 4+ levels of nesting
|
|
126
|
+
];
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Analysis Functions
|
|
129
|
+
// ============================================================================
|
|
130
|
+
export function shouldExcludeFile(filePath) {
|
|
131
|
+
const excludePatterns = [
|
|
132
|
+
/\.test\.[jt]sx?$/,
|
|
133
|
+
/\.spec\.[jt]sx?$/,
|
|
134
|
+
/__tests__\//,
|
|
135
|
+
/node_modules\//,
|
|
136
|
+
/\.min\.[jt]s$/,
|
|
137
|
+
];
|
|
138
|
+
return excludePatterns.some((p) => p.test(filePath));
|
|
139
|
+
}
|
|
140
|
+
function detectBuiltInUtility(content, filePath, patterns, type, utilityName) {
|
|
141
|
+
const results = [];
|
|
142
|
+
const lines = content.split('\n');
|
|
143
|
+
for (let i = 0; i < lines.length; i++) {
|
|
144
|
+
const line = lines[i];
|
|
145
|
+
for (const pattern of patterns) {
|
|
146
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
147
|
+
let match;
|
|
148
|
+
while ((match = regex.exec(line)) !== null) {
|
|
149
|
+
results.push({
|
|
150
|
+
type,
|
|
151
|
+
file: filePath,
|
|
152
|
+
line: i + 1,
|
|
153
|
+
column: match.index + 1,
|
|
154
|
+
matchedText: match[0],
|
|
155
|
+
utilityName,
|
|
156
|
+
targetType: match[1],
|
|
157
|
+
isBuiltIn: true,
|
|
158
|
+
context: line.trim(),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return results;
|
|
164
|
+
}
|
|
165
|
+
export function detectPartial(content, filePath) {
|
|
166
|
+
return detectBuiltInUtility(content, filePath, PARTIAL_PATTERNS, 'partial', 'Partial');
|
|
167
|
+
}
|
|
168
|
+
export function detectRequired(content, filePath) {
|
|
169
|
+
return detectBuiltInUtility(content, filePath, REQUIRED_PATTERNS, 'required', 'Required');
|
|
170
|
+
}
|
|
171
|
+
export function detectReadonly(content, filePath) {
|
|
172
|
+
return detectBuiltInUtility(content, filePath, READONLY_PATTERNS, 'readonly', 'Readonly');
|
|
173
|
+
}
|
|
174
|
+
export function detectPick(content, filePath) {
|
|
175
|
+
return detectBuiltInUtility(content, filePath, PICK_PATTERNS, 'pick', 'Pick');
|
|
176
|
+
}
|
|
177
|
+
export function detectOmit(content, filePath) {
|
|
178
|
+
return detectBuiltInUtility(content, filePath, OMIT_PATTERNS, 'omit', 'Omit');
|
|
179
|
+
}
|
|
180
|
+
export function detectRecord(content, filePath) {
|
|
181
|
+
return detectBuiltInUtility(content, filePath, RECORD_PATTERNS, 'record', 'Record');
|
|
182
|
+
}
|
|
183
|
+
export function detectExclude(content, filePath) {
|
|
184
|
+
return detectBuiltInUtility(content, filePath, EXCLUDE_PATTERNS, 'exclude', 'Exclude');
|
|
185
|
+
}
|
|
186
|
+
export function detectExtract(content, filePath) {
|
|
187
|
+
return detectBuiltInUtility(content, filePath, EXTRACT_PATTERNS, 'extract', 'Extract');
|
|
188
|
+
}
|
|
189
|
+
export function detectNonNullable(content, filePath) {
|
|
190
|
+
return detectBuiltInUtility(content, filePath, NON_NULLABLE_PATTERNS, 'non-nullable', 'NonNullable');
|
|
191
|
+
}
|
|
192
|
+
export function detectReturnType(content, filePath) {
|
|
193
|
+
return detectBuiltInUtility(content, filePath, RETURN_TYPE_PATTERNS, 'return-type', 'ReturnType');
|
|
194
|
+
}
|
|
195
|
+
export function detectParameters(content, filePath) {
|
|
196
|
+
return detectBuiltInUtility(content, filePath, PARAMETERS_PATTERNS, 'parameters', 'Parameters');
|
|
197
|
+
}
|
|
198
|
+
export function detectInstanceType(content, filePath) {
|
|
199
|
+
return detectBuiltInUtility(content, filePath, INSTANCE_TYPE_PATTERNS, 'instance-type', 'InstanceType');
|
|
200
|
+
}
|
|
201
|
+
export function detectAwaited(content, filePath) {
|
|
202
|
+
return detectBuiltInUtility(content, filePath, AWAITED_PATTERNS, 'awaited', 'Awaited');
|
|
203
|
+
}
|
|
204
|
+
export function detectThisType(content, filePath) {
|
|
205
|
+
return detectBuiltInUtility(content, filePath, THIS_TYPE_PATTERNS, 'this-type', 'ThisType');
|
|
206
|
+
}
|
|
207
|
+
export function detectCustomMapped(content, filePath) {
|
|
208
|
+
const results = [];
|
|
209
|
+
const lines = content.split('\n');
|
|
210
|
+
for (let i = 0; i < lines.length; i++) {
|
|
211
|
+
const line = lines[i];
|
|
212
|
+
for (const pattern of CUSTOM_MAPPED_PATTERNS) {
|
|
213
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
214
|
+
let match;
|
|
215
|
+
while ((match = regex.exec(line)) !== null) {
|
|
216
|
+
results.push({
|
|
217
|
+
type: 'custom-mapped',
|
|
218
|
+
file: filePath,
|
|
219
|
+
line: i + 1,
|
|
220
|
+
column: match.index + 1,
|
|
221
|
+
matchedText: match[0],
|
|
222
|
+
utilityName: match[1] || 'mapped-type',
|
|
223
|
+
isBuiltIn: false,
|
|
224
|
+
context: line.trim(),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return results;
|
|
230
|
+
}
|
|
231
|
+
export function detectCustomConditional(content, filePath) {
|
|
232
|
+
const results = [];
|
|
233
|
+
const lines = content.split('\n');
|
|
234
|
+
for (let i = 0; i < lines.length; i++) {
|
|
235
|
+
const line = lines[i];
|
|
236
|
+
for (const pattern of CUSTOM_CONDITIONAL_PATTERNS) {
|
|
237
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
238
|
+
let match;
|
|
239
|
+
while ((match = regex.exec(line)) !== null) {
|
|
240
|
+
results.push({
|
|
241
|
+
type: 'custom-conditional',
|
|
242
|
+
file: filePath,
|
|
243
|
+
line: i + 1,
|
|
244
|
+
column: match.index + 1,
|
|
245
|
+
matchedText: match[0],
|
|
246
|
+
utilityName: match[1],
|
|
247
|
+
isBuiltIn: false,
|
|
248
|
+
context: line.trim(),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return results;
|
|
254
|
+
}
|
|
255
|
+
export function detectTemplateLiteral(content, filePath) {
|
|
256
|
+
const results = [];
|
|
257
|
+
const lines = content.split('\n');
|
|
258
|
+
for (let i = 0; i < lines.length; i++) {
|
|
259
|
+
const line = lines[i];
|
|
260
|
+
for (const pattern of TEMPLATE_LITERAL_PATTERNS) {
|
|
261
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
262
|
+
let match;
|
|
263
|
+
while ((match = regex.exec(line)) !== null) {
|
|
264
|
+
results.push({
|
|
265
|
+
type: 'template-literal',
|
|
266
|
+
file: filePath,
|
|
267
|
+
line: i + 1,
|
|
268
|
+
column: match.index + 1,
|
|
269
|
+
matchedText: match[0],
|
|
270
|
+
utilityName: match[1] || 'template-literal',
|
|
271
|
+
isBuiltIn: /^(Uppercase|Lowercase|Capitalize|Uncapitalize)/.test(match[0]),
|
|
272
|
+
context: line.trim(),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return results;
|
|
278
|
+
}
|
|
279
|
+
export function detectRecursiveType(content, filePath) {
|
|
280
|
+
const results = [];
|
|
281
|
+
const lines = content.split('\n');
|
|
282
|
+
for (let i = 0; i < lines.length; i++) {
|
|
283
|
+
const line = lines[i];
|
|
284
|
+
for (const pattern of RECURSIVE_TYPE_PATTERNS) {
|
|
285
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
286
|
+
let match;
|
|
287
|
+
while ((match = regex.exec(line)) !== null) {
|
|
288
|
+
results.push({
|
|
289
|
+
type: 'recursive-type',
|
|
290
|
+
file: filePath,
|
|
291
|
+
line: i + 1,
|
|
292
|
+
column: match.index + 1,
|
|
293
|
+
matchedText: match[0],
|
|
294
|
+
utilityName: match[1],
|
|
295
|
+
isBuiltIn: false,
|
|
296
|
+
context: line.trim(),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return results;
|
|
302
|
+
}
|
|
303
|
+
export function detectBrandedType(content, filePath) {
|
|
304
|
+
const results = [];
|
|
305
|
+
const lines = content.split('\n');
|
|
306
|
+
for (let i = 0; i < lines.length; i++) {
|
|
307
|
+
const line = lines[i];
|
|
308
|
+
for (const pattern of BRANDED_TYPE_PATTERNS) {
|
|
309
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
310
|
+
let match;
|
|
311
|
+
while ((match = regex.exec(line)) !== null) {
|
|
312
|
+
results.push({
|
|
313
|
+
type: 'branded-type',
|
|
314
|
+
file: filePath,
|
|
315
|
+
line: i + 1,
|
|
316
|
+
column: match.index + 1,
|
|
317
|
+
matchedText: match[0],
|
|
318
|
+
utilityName: match[1] || 'branded-type',
|
|
319
|
+
isBuiltIn: false,
|
|
320
|
+
context: line.trim(),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return results;
|
|
326
|
+
}
|
|
327
|
+
export function detectDeepPartial(content, filePath) {
|
|
328
|
+
const results = [];
|
|
329
|
+
const lines = content.split('\n');
|
|
330
|
+
for (let i = 0; i < lines.length; i++) {
|
|
331
|
+
const line = lines[i];
|
|
332
|
+
for (const pattern of DEEP_PARTIAL_PATTERNS) {
|
|
333
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
334
|
+
let match;
|
|
335
|
+
while ((match = regex.exec(line)) !== null) {
|
|
336
|
+
results.push({
|
|
337
|
+
type: 'deep-partial',
|
|
338
|
+
file: filePath,
|
|
339
|
+
line: i + 1,
|
|
340
|
+
column: match.index + 1,
|
|
341
|
+
matchedText: match[0],
|
|
342
|
+
utilityName: 'DeepPartial',
|
|
343
|
+
targetType: match[1],
|
|
344
|
+
isBuiltIn: false,
|
|
345
|
+
context: line.trim(),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return results;
|
|
351
|
+
}
|
|
352
|
+
export function detectDeepReadonly(content, filePath) {
|
|
353
|
+
const results = [];
|
|
354
|
+
const lines = content.split('\n');
|
|
355
|
+
for (let i = 0; i < lines.length; i++) {
|
|
356
|
+
const line = lines[i];
|
|
357
|
+
for (const pattern of DEEP_READONLY_PATTERNS) {
|
|
358
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
359
|
+
let match;
|
|
360
|
+
while ((match = regex.exec(line)) !== null) {
|
|
361
|
+
results.push({
|
|
362
|
+
type: 'deep-readonly',
|
|
363
|
+
file: filePath,
|
|
364
|
+
line: i + 1,
|
|
365
|
+
column: match.index + 1,
|
|
366
|
+
matchedText: match[0],
|
|
367
|
+
utilityName: 'DeepReadonly',
|
|
368
|
+
targetType: match[1],
|
|
369
|
+
isBuiltIn: false,
|
|
370
|
+
context: line.trim(),
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return results;
|
|
376
|
+
}
|
|
377
|
+
export function detectRedundantUtilityViolations(content, filePath) {
|
|
378
|
+
const results = [];
|
|
379
|
+
const lines = content.split('\n');
|
|
380
|
+
for (let i = 0; i < lines.length; i++) {
|
|
381
|
+
const line = lines[i];
|
|
382
|
+
for (const pattern of REDUNDANT_UTILITY_PATTERNS) {
|
|
383
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
384
|
+
let match;
|
|
385
|
+
while ((match = regex.exec(line)) !== null) {
|
|
386
|
+
results.push({
|
|
387
|
+
type: 'redundant-utility',
|
|
388
|
+
file: filePath,
|
|
389
|
+
line: i + 1,
|
|
390
|
+
column: match.index + 1,
|
|
391
|
+
matchedText: match[0],
|
|
392
|
+
issue: 'Redundant nested utility type',
|
|
393
|
+
suggestedFix: 'Remove the outer utility type',
|
|
394
|
+
severity: 'low',
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return results;
|
|
400
|
+
}
|
|
401
|
+
export function detectNestedUtilityViolations(content, filePath) {
|
|
402
|
+
const results = [];
|
|
403
|
+
const lines = content.split('\n');
|
|
404
|
+
for (let i = 0; i < lines.length; i++) {
|
|
405
|
+
const line = lines[i];
|
|
406
|
+
for (const pattern of NESTED_UTILITY_PATTERNS) {
|
|
407
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
408
|
+
let match;
|
|
409
|
+
while ((match = regex.exec(line)) !== null) {
|
|
410
|
+
results.push({
|
|
411
|
+
type: 'nested-utility',
|
|
412
|
+
file: filePath,
|
|
413
|
+
line: i + 1,
|
|
414
|
+
column: match.index + 1,
|
|
415
|
+
matchedText: match[0],
|
|
416
|
+
issue: 'Potentially conflicting nested utility types',
|
|
417
|
+
suggestedFix: 'Consider simplifying or using a custom type',
|
|
418
|
+
severity: 'medium',
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return results;
|
|
424
|
+
}
|
|
425
|
+
export function detectComplexUtilityChainViolations(content, filePath) {
|
|
426
|
+
const results = [];
|
|
427
|
+
const lines = content.split('\n');
|
|
428
|
+
for (let i = 0; i < lines.length; i++) {
|
|
429
|
+
const line = lines[i];
|
|
430
|
+
for (const pattern of COMPLEX_UTILITY_CHAIN_PATTERNS) {
|
|
431
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
432
|
+
let match;
|
|
433
|
+
while ((match = regex.exec(line)) !== null) {
|
|
434
|
+
results.push({
|
|
435
|
+
type: 'complex-utility-chain',
|
|
436
|
+
file: filePath,
|
|
437
|
+
line: i + 1,
|
|
438
|
+
column: match.index + 1,
|
|
439
|
+
matchedText: match[0],
|
|
440
|
+
issue: 'Complex utility type chain (4+ levels)',
|
|
441
|
+
suggestedFix: 'Break into intermediate types for readability',
|
|
442
|
+
severity: 'medium',
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return results;
|
|
448
|
+
}
|
|
449
|
+
export function analyzeUtilityTypes(content, filePath) {
|
|
450
|
+
if (shouldExcludeFile(filePath)) {
|
|
451
|
+
return {
|
|
452
|
+
patterns: [],
|
|
453
|
+
violations: [],
|
|
454
|
+
builtInCount: 0,
|
|
455
|
+
customCount: 0,
|
|
456
|
+
usesDeepUtilities: false,
|
|
457
|
+
usesBrandedTypes: false,
|
|
458
|
+
confidence: 1.0,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
const patterns = [
|
|
462
|
+
...detectPartial(content, filePath),
|
|
463
|
+
...detectRequired(content, filePath),
|
|
464
|
+
...detectReadonly(content, filePath),
|
|
465
|
+
...detectPick(content, filePath),
|
|
466
|
+
...detectOmit(content, filePath),
|
|
467
|
+
...detectRecord(content, filePath),
|
|
468
|
+
...detectExclude(content, filePath),
|
|
469
|
+
...detectExtract(content, filePath),
|
|
470
|
+
...detectNonNullable(content, filePath),
|
|
471
|
+
...detectReturnType(content, filePath),
|
|
472
|
+
...detectParameters(content, filePath),
|
|
473
|
+
...detectInstanceType(content, filePath),
|
|
474
|
+
...detectAwaited(content, filePath),
|
|
475
|
+
...detectThisType(content, filePath),
|
|
476
|
+
...detectCustomMapped(content, filePath),
|
|
477
|
+
...detectCustomConditional(content, filePath),
|
|
478
|
+
...detectTemplateLiteral(content, filePath),
|
|
479
|
+
...detectRecursiveType(content, filePath),
|
|
480
|
+
...detectBrandedType(content, filePath),
|
|
481
|
+
...detectDeepPartial(content, filePath),
|
|
482
|
+
...detectDeepReadonly(content, filePath),
|
|
483
|
+
];
|
|
484
|
+
const violations = [
|
|
485
|
+
...detectRedundantUtilityViolations(content, filePath),
|
|
486
|
+
...detectNestedUtilityViolations(content, filePath),
|
|
487
|
+
...detectComplexUtilityChainViolations(content, filePath),
|
|
488
|
+
];
|
|
489
|
+
const builtInCount = patterns.filter((p) => p.isBuiltIn).length;
|
|
490
|
+
const customCount = patterns.filter((p) => !p.isBuiltIn).length;
|
|
491
|
+
const usesDeepUtilities = patterns.some((p) => p.type === 'deep-partial' || p.type === 'deep-readonly');
|
|
492
|
+
const usesBrandedTypes = patterns.some((p) => p.type === 'branded-type');
|
|
493
|
+
let confidence = 0.7;
|
|
494
|
+
if (patterns.length > 0)
|
|
495
|
+
confidence += 0.15;
|
|
496
|
+
if (builtInCount > 0)
|
|
497
|
+
confidence += 0.05;
|
|
498
|
+
if (violations.length === 0)
|
|
499
|
+
confidence += 0.05;
|
|
500
|
+
confidence = Math.min(confidence, 0.95);
|
|
501
|
+
return {
|
|
502
|
+
patterns,
|
|
503
|
+
violations,
|
|
504
|
+
builtInCount,
|
|
505
|
+
customCount,
|
|
506
|
+
usesDeepUtilities,
|
|
507
|
+
usesBrandedTypes,
|
|
508
|
+
confidence,
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
// ============================================================================
|
|
512
|
+
// Detector Class
|
|
513
|
+
// ============================================================================
|
|
514
|
+
export class UtilityTypesDetector extends RegexDetector {
|
|
515
|
+
id = 'types/utility-types';
|
|
516
|
+
name = 'Utility Types Detector';
|
|
517
|
+
description = 'Detects TypeScript utility type patterns including built-in and custom utilities';
|
|
518
|
+
category = 'types';
|
|
519
|
+
subcategory = 'utility-types';
|
|
520
|
+
supportedLanguages = ['typescript'];
|
|
521
|
+
async detect(context) {
|
|
522
|
+
if (!this.supportsLanguage(context.language)) {
|
|
523
|
+
return this.createEmptyResult();
|
|
524
|
+
}
|
|
525
|
+
const analysis = analyzeUtilityTypes(context.content, context.file);
|
|
526
|
+
if (analysis.patterns.length === 0 && analysis.violations.length === 0) {
|
|
527
|
+
return this.createEmptyResult();
|
|
528
|
+
}
|
|
529
|
+
return this.createResult([], [], analysis.confidence, {
|
|
530
|
+
custom: {
|
|
531
|
+
patterns: analysis.patterns,
|
|
532
|
+
violations: analysis.violations,
|
|
533
|
+
builtInCount: analysis.builtInCount,
|
|
534
|
+
customCount: analysis.customCount,
|
|
535
|
+
usesDeepUtilities: analysis.usesDeepUtilities,
|
|
536
|
+
usesBrandedTypes: analysis.usesBrandedTypes,
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
generateQuickFix(_violation) {
|
|
541
|
+
return null;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
export function createUtilityTypesDetector() {
|
|
545
|
+
return new UtilityTypesDetector();
|
|
546
|
+
}
|
|
547
|
+
//# sourceMappingURL=utility-types.js.map
|