@nanas-home/hub-common 0.40.915 → 0.42.947
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/chunk/{A72V2BCC.js → FTJ4R6VS.js} +113 -56
- package/dist/eslint/index.js +7 -0
- package/dist/eslint/rules/require-debug-marker.js +37 -0
- package/dist/index.css +1 -1
- package/dist/node-utils/index.d.ts +17 -3
- package/dist/node-utils/index.js +99 -68
- package/dist/{textValidation-D1wlgtFs.d.ts → textValidation-B9dDNzjQ.d.ts} +97 -24
- package/dist/web/index.d.ts +45 -22
- package/dist/web/index.js +640 -251
- package/dist/web/index.jsx +1238 -63454
- package/package.json +16 -10
|
@@ -99,6 +99,7 @@ var apiRouteParam = {
|
|
|
99
99
|
addressUuid: ":addressUuid",
|
|
100
100
|
bookingUuid: ":bookingUuid",
|
|
101
101
|
bookingAddonUuid: ":bookingAddonUuid",
|
|
102
|
+
userMembershipUuid: ":userMembershipUuid",
|
|
102
103
|
linkUuid: ":linkUuid",
|
|
103
104
|
linkType: ":linkType",
|
|
104
105
|
// Stripe
|
|
@@ -240,9 +241,10 @@ var apiRoute = {
|
|
|
240
241
|
prefix: "/payment-method",
|
|
241
242
|
getByForUser: `/user`,
|
|
242
243
|
prepareCreateForUser: `/user/setup`,
|
|
244
|
+
setDefaultPaymentMethod: `/default/${apiRouteParam.stripeId}`,
|
|
243
245
|
createForUser: `/user`,
|
|
244
246
|
deleteForUser: `/${apiRouteParam.stripeId}`,
|
|
245
|
-
swagger: { name: "
|
|
247
|
+
swagger: { name: "PaymentMethods", description: "Endpoints for User to view their Payment Methods" }
|
|
246
248
|
}
|
|
247
249
|
},
|
|
248
250
|
membership: {
|
|
@@ -274,6 +276,11 @@ var apiRoute = {
|
|
|
274
276
|
},
|
|
275
277
|
userMembership: {
|
|
276
278
|
prefix: "/user-membership",
|
|
279
|
+
getForCurrentUser: "",
|
|
280
|
+
signUpForSubscription: "/sign-up",
|
|
281
|
+
pause: `/${apiRouteParam.userMembershipUuid}/pause`,
|
|
282
|
+
resume: `/${apiRouteParam.userMembershipUuid}/resume`,
|
|
283
|
+
cancel: `/${apiRouteParam.userMembershipUuid}/cancel`,
|
|
277
284
|
bookingDays: "/booking-days",
|
|
278
285
|
swagger: { name: "UserMembership", description: "Endpoints for User to get info about their Memberships" }
|
|
279
286
|
}
|
|
@@ -349,14 +356,25 @@ var InvoiceStatusType = /* @__PURE__ */ ((InvoiceStatusType2) => {
|
|
|
349
356
|
return InvoiceStatusType2;
|
|
350
357
|
})(InvoiceStatusType || {});
|
|
351
358
|
|
|
359
|
+
// src/contracts/generated/enum/membershipBillingCycleType.ts
|
|
360
|
+
var MembershipBillingCycleType = /* @__PURE__ */ ((MembershipBillingCycleType2) => {
|
|
361
|
+
MembershipBillingCycleType2[MembershipBillingCycleType2["Unknown"] = 0] = "Unknown";
|
|
362
|
+
MembershipBillingCycleType2[MembershipBillingCycleType2["Monthly"] = 2] = "Monthly";
|
|
363
|
+
MembershipBillingCycleType2[MembershipBillingCycleType2["Yearly"] = 3] = "Yearly";
|
|
364
|
+
return MembershipBillingCycleType2;
|
|
365
|
+
})(MembershipBillingCycleType || {});
|
|
366
|
+
|
|
352
367
|
// src/contracts/generated/enum/membershipStatus.ts
|
|
353
368
|
var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
|
|
354
369
|
MembershipStatus2[MembershipStatus2["Unknown"] = 0] = "Unknown";
|
|
355
370
|
MembershipStatus2[MembershipStatus2["Active"] = 1] = "Active";
|
|
356
|
-
MembershipStatus2[MembershipStatus2["
|
|
357
|
-
MembershipStatus2[MembershipStatus2["
|
|
358
|
-
MembershipStatus2[MembershipStatus2["
|
|
359
|
-
MembershipStatus2[MembershipStatus2["
|
|
371
|
+
MembershipStatus2[MembershipStatus2["Paused"] = 10] = "Paused";
|
|
372
|
+
MembershipStatus2[MembershipStatus2["Trialing"] = 11] = "Trialing";
|
|
373
|
+
MembershipStatus2[MembershipStatus2["Unpaid"] = 12] = "Unpaid";
|
|
374
|
+
MembershipStatus2[MembershipStatus2["Cancelled"] = 20] = "Cancelled";
|
|
375
|
+
MembershipStatus2[MembershipStatus2["Incomplete"] = 21] = "Incomplete";
|
|
376
|
+
MembershipStatus2[MembershipStatus2["IncompleteExpired"] = 22] = "IncompleteExpired";
|
|
377
|
+
MembershipStatus2[MembershipStatus2["PastDue"] = 23] = "PastDue";
|
|
360
378
|
return MembershipStatus2;
|
|
361
379
|
})(MembershipStatus || {});
|
|
362
380
|
|
|
@@ -443,6 +461,7 @@ var PetStatusType = /* @__PURE__ */ ((PetStatusType2) => {
|
|
|
443
461
|
PetStatusType2[PetStatusType2["Active"] = 1] = "Active";
|
|
444
462
|
PetStatusType2[PetStatusType2["Deceased"] = 2] = "Deceased";
|
|
445
463
|
PetStatusType2[PetStatusType2["Blacklisted"] = 3] = "Blacklisted";
|
|
464
|
+
PetStatusType2[PetStatusType2["Removed"] = 4] = "Removed";
|
|
446
465
|
return PetStatusType2;
|
|
447
466
|
})(PetStatusType || {});
|
|
448
467
|
|
|
@@ -581,7 +600,9 @@ var MembershipRestriction = {
|
|
|
581
600
|
matchFee: { minValue: 0, maxValue: 1e3 },
|
|
582
601
|
freeCancellationWithinDays: { minValue: 0, maxValue: 1e3 },
|
|
583
602
|
bookingAdvanceDays: { minValue: 0, maxValue: 1e3 },
|
|
584
|
-
bookingCalenderMonthsOpenInAdvance: { minValue: 0, maxValue: 1e3 }
|
|
603
|
+
bookingCalenderMonthsOpenInAdvance: { minValue: 0, maxValue: 1e3 },
|
|
604
|
+
stripeMonthlyProductId: { minLength: 3, maxLength: 80 },
|
|
605
|
+
stripeYearlyProductId: { minLength: 3, maxLength: 80 }
|
|
585
606
|
};
|
|
586
607
|
|
|
587
608
|
// src/contracts/generated/restrictions/permissionRestriction.ts
|
|
@@ -671,6 +692,55 @@ var arrayContains = (arr, items, method = "AND") => {
|
|
|
671
692
|
}
|
|
672
693
|
return true;
|
|
673
694
|
};
|
|
695
|
+
|
|
696
|
+
// src/services/internal/config/commonConfigService.ts
|
|
697
|
+
var CommonConfigService = class {
|
|
698
|
+
_internalIsProd;
|
|
699
|
+
getHubApiUrl = () => this.get("VITE_HUB_API_URL");
|
|
700
|
+
getHubLandingUrl = () => this.get("VITE_HUB_LANDING_URL");
|
|
701
|
+
getHubClientUrl = () => this.get("VITE_HUB_CLIENT_URL");
|
|
702
|
+
getHubAdminUrl = () => this.get("VITE_HUB_ADMIN_URL");
|
|
703
|
+
getHubCoverageUrl = () => this.get("VITE_HUB_COVERAGE_URL");
|
|
704
|
+
getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
|
|
705
|
+
getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
|
|
706
|
+
getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
|
|
707
|
+
// HCaptcha
|
|
708
|
+
getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
|
|
709
|
+
getHCaptchaSecret = () => this.get("HCAPTCHA_SECRET");
|
|
710
|
+
getHCaptchaSiteKey = () => this.get("VITE_HCAPTCHA_SITE_KEY");
|
|
711
|
+
// Tolgee
|
|
712
|
+
getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
|
|
713
|
+
getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
|
|
714
|
+
getTolgeeProjectId = () => this.getNumber("VITE_TOLGEE_PROJECT_ID");
|
|
715
|
+
/* Special case, available on UI & API */
|
|
716
|
+
isProd = () => {
|
|
717
|
+
if (this._internalIsProd == null) {
|
|
718
|
+
this._internalIsProd = this.get("NODE_ENV").toLocaleLowerCase() === "production" || this.get("MODE").toLocaleLowerCase() === "production";
|
|
719
|
+
}
|
|
720
|
+
return this._internalIsProd;
|
|
721
|
+
};
|
|
722
|
+
packageVersion = () => this.getWithFallback("npm_package_version", "PACKAGE_VERSION");
|
|
723
|
+
getConsoleLogLevels = () => {
|
|
724
|
+
const envVar = this.get("VITE_CONSOLE_LOGGING");
|
|
725
|
+
if (envVar?.length < 1) return ["trace", "log", "info", "debug", "warn", "error"];
|
|
726
|
+
return envVar.split(",").map((l) => l);
|
|
727
|
+
};
|
|
728
|
+
get(property, defaultValue) {
|
|
729
|
+
let value = void 0;
|
|
730
|
+
value = import.meta.env?.[property];
|
|
731
|
+
if (defaultValue != null) {
|
|
732
|
+
return value ?? defaultValue;
|
|
733
|
+
}
|
|
734
|
+
return value ?? "";
|
|
735
|
+
}
|
|
736
|
+
getWithFallback = (property, fallbackProperty, defaultValue) => {
|
|
737
|
+
const orig = this.get(property);
|
|
738
|
+
if (orig != null) return orig;
|
|
739
|
+
return this.get(fallbackProperty, defaultValue);
|
|
740
|
+
};
|
|
741
|
+
getBool = (property, defaultValue) => this.get(property, defaultValue).toLowerCase() == "true";
|
|
742
|
+
getNumber = (property, defaultValue) => Number(this.get(property, defaultValue?.toString?.()));
|
|
743
|
+
};
|
|
674
744
|
var formatDate = (date, format = "DD MMM YYYY HH:mm") => {
|
|
675
745
|
const dateStr = dayjs(date).format(format);
|
|
676
746
|
if (dateStr.includes("Invalid")) return "";
|
|
@@ -722,55 +792,6 @@ var showSecondCalendar = (startDateStr, endDateStr) => {
|
|
|
722
792
|
return true;
|
|
723
793
|
};
|
|
724
794
|
|
|
725
|
-
// src/services/internal/config/commonConfigService.ts
|
|
726
|
-
var CommonConfigService = class {
|
|
727
|
-
_internalIsProd;
|
|
728
|
-
getHubApiUrl = () => this.get("VITE_HUB_API_URL");
|
|
729
|
-
getHubLandingUrl = () => this.get("VITE_HUB_LANDING_URL");
|
|
730
|
-
getHubClientUrl = () => this.get("VITE_HUB_CLIENT_URL");
|
|
731
|
-
getHubAdminUrl = () => this.get("VITE_HUB_ADMIN_URL");
|
|
732
|
-
getHubCoverageUrl = () => this.get("VITE_HUB_COVERAGE_URL");
|
|
733
|
-
getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
|
|
734
|
-
getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
|
|
735
|
-
getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
|
|
736
|
-
// HCaptcha
|
|
737
|
-
getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
|
|
738
|
-
getHCaptchaSecret = () => this.get("HCAPTCHA_SECRET");
|
|
739
|
-
getHCaptchaSiteKey = () => this.get("VITE_HCAPTCHA_SITE_KEY");
|
|
740
|
-
// Tolgee
|
|
741
|
-
getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
|
|
742
|
-
getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
|
|
743
|
-
getTolgeeProjectId = () => this.getNumber("VITE_TOLGEE_PROJECT_ID");
|
|
744
|
-
/* Special case, available on UI & API */
|
|
745
|
-
isProd = () => {
|
|
746
|
-
if (this._internalIsProd == null) {
|
|
747
|
-
this._internalIsProd = this.get("NODE_ENV").toLocaleLowerCase() === "production" || this.get("MODE").toLocaleLowerCase() === "production";
|
|
748
|
-
}
|
|
749
|
-
return this._internalIsProd;
|
|
750
|
-
};
|
|
751
|
-
packageVersion = () => this.getWithFallback("npm_package_version", "PACKAGE_VERSION");
|
|
752
|
-
getConsoleLogLevels = () => {
|
|
753
|
-
const envVar = this.get("VITE_CONSOLE_LOGGING");
|
|
754
|
-
if (envVar?.length < 1) return ["trace", "log", "info", "debug", "warn", "error"];
|
|
755
|
-
return envVar.split(",").map((l) => l);
|
|
756
|
-
};
|
|
757
|
-
get(property, defaultValue) {
|
|
758
|
-
let value = void 0;
|
|
759
|
-
value = import.meta.env?.[property];
|
|
760
|
-
if (defaultValue != null) {
|
|
761
|
-
return value ?? defaultValue;
|
|
762
|
-
}
|
|
763
|
-
return value ?? "";
|
|
764
|
-
}
|
|
765
|
-
getWithFallback = (property, fallbackProperty, defaultValue) => {
|
|
766
|
-
const orig = this.get(property);
|
|
767
|
-
if (orig != null) return orig;
|
|
768
|
-
return this.get(fallbackProperty, defaultValue);
|
|
769
|
-
};
|
|
770
|
-
getBool = (property, defaultValue) => this.get(property, defaultValue).toLowerCase() == "true";
|
|
771
|
-
getNumber = (property, defaultValue) => Number(this.get(property, defaultValue?.toString?.()));
|
|
772
|
-
};
|
|
773
|
-
|
|
774
795
|
// src/services/internal/log/logService.ts
|
|
775
796
|
var LogService = class {
|
|
776
797
|
constructor(config, _logToConsole = true, _onLogMessage, _numDaysToKeep = 100) {
|
|
@@ -1348,6 +1369,24 @@ var urlRef = (url) => {
|
|
|
1348
1369
|
return url + `?ref=${ref}`;
|
|
1349
1370
|
};
|
|
1350
1371
|
|
|
1372
|
+
// src/helpers/userMembershipHelper.ts
|
|
1373
|
+
var getActiveUserMembership = (userMemberships) => {
|
|
1374
|
+
const now = /* @__PURE__ */ new Date();
|
|
1375
|
+
return userMemberships.find((m) => {
|
|
1376
|
+
if (isBefore(now, m.startDate)) return false;
|
|
1377
|
+
if (m.endDate != null) {
|
|
1378
|
+
if (isBefore(m.endDate, now)) return false;
|
|
1379
|
+
}
|
|
1380
|
+
const badStatuses = [
|
|
1381
|
+
0 /* Unknown */,
|
|
1382
|
+
20 /* Cancelled */,
|
|
1383
|
+
23 /* PastDue */,
|
|
1384
|
+
12 /* Unpaid */
|
|
1385
|
+
];
|
|
1386
|
+
return badStatuses.includes(m.status) == false;
|
|
1387
|
+
});
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1351
1390
|
// src/services/internal/config/colour.config.ts
|
|
1352
1391
|
var colourPalette = {
|
|
1353
1392
|
nanasBackyard: "#97A571",
|
|
@@ -1366,6 +1405,24 @@ var defaultSiteColour = {
|
|
|
1366
1405
|
primary: "#97A571",
|
|
1367
1406
|
secondary: "#97A571"
|
|
1368
1407
|
};
|
|
1408
|
+
|
|
1409
|
+
// src/services/internal/debug/debugService.ts
|
|
1410
|
+
var DebugService = class {
|
|
1411
|
+
_setDebug(e) {
|
|
1412
|
+
if (e.code == "ControlLeft") {
|
|
1413
|
+
document.body.classList.add("debug");
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
_removeDebug(e) {
|
|
1417
|
+
if (e.code == "ControlLeft") {
|
|
1418
|
+
document.body.classList.remove("debug");
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
setupGlobalDebugKey = () => {
|
|
1422
|
+
document.addEventListener("keydown", this._setDebug);
|
|
1423
|
+
document.addEventListener("keyup", this._removeDebug);
|
|
1424
|
+
};
|
|
1425
|
+
};
|
|
1369
1426
|
var TranslationService = class {
|
|
1370
1427
|
constructor(log, _config) {
|
|
1371
1428
|
this._config = _config;
|
|
@@ -1618,4 +1675,4 @@ var shouldBeYoutubeUrl = (value) => {
|
|
|
1618
1675
|
};
|
|
1619
1676
|
};
|
|
1620
1677
|
|
|
1621
|
-
export { APP_TYPE_TOKEN, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, BOT_PATH_TOKEN, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, CommentLinkType, CommentRestriction, CommonConfigService, DependencyInjectionContainer, DrivingRouteRestriction, InvoiceRestriction, InvoiceStatusType, LogService, MembershipRestriction, MembershipStatus, MembershipType, MouseButton, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG_TOKEN, SearchableColumnType, StripeRestriction, TranslationService, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiRoute, apiRouteParam, arrayContains, arrayOfNLength, capitalizeFirstLetter, changeMonth, colourPalette, convertToDate, convertToFullDateSelection, createToken, cyrb53, dateDiffInDays, debounceLeading, defaultSiteColour, fakePromise, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getAgeInYears, getAllPetQuestionForType, getAppType, getArrFromEnum, getBotPath, getCalendarDropdownDisplayValue, getCalendarDropdownForDateOfBirthDisplayValue, getCommonConfig, getDayClassObject, getDayElements, getDayHeadingElements, getImageParams, getLog, getMimeTypeFromExtension, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getSiteColour, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, isBefore, isDateAfterStart, isDateBeforeEnd, isDateDisabledByDisabledDays, isDateEnabledByEnabledDays, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxItems, maxLength, maxValue, mimeTypeLookup, minDate, minItems, minLength, minUrlLength, minValue, monthTranslationKeyOrder, multiValidation, nameof, nanasFonts, noValidation, notNull, onlyUnique, portalGlyphLength, promiseFromValue, randomIntFromRange, randomItemFromArray, rootContainer, rootDependencyInjectionSetup, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, setContainerToken, setContainerTokenLazy, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, showSecondCalendar, socialLinks, timeout, tryParseNumber, uploadsThatNeedEncryption, urlRef, uuidv4, validUuidChars, validateForEach, webAppTypes, weekdayTranslationKeyOrder };
|
|
1678
|
+
export { APP_TYPE_TOKEN, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, BOT_PATH_TOKEN, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, CommentLinkType, CommentRestriction, CommonConfigService, DebugService, DependencyInjectionContainer, DrivingRouteRestriction, InvoiceRestriction, InvoiceStatusType, LogService, MembershipBillingCycleType, MembershipRestriction, MembershipStatus, MembershipType, MouseButton, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG_TOKEN, SearchableColumnType, StripeRestriction, TranslationService, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiRoute, apiRouteParam, arrayContains, arrayOfNLength, capitalizeFirstLetter, changeMonth, colourPalette, convertToDate, convertToFullDateSelection, createToken, cyrb53, dateDiffInDays, debounceLeading, defaultSiteColour, fakePromise, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getActiveUserMembership, getAgeInYears, getAllPetQuestionForType, getAppType, getArrFromEnum, getBotPath, getCalendarDropdownDisplayValue, getCalendarDropdownForDateOfBirthDisplayValue, getCommonConfig, getDayClassObject, getDayElements, getDayHeadingElements, getImageParams, getLog, getMimeTypeFromExtension, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getSiteColour, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, isBefore, isDateAfterStart, isDateBeforeEnd, isDateDisabledByDisabledDays, isDateEnabledByEnabledDays, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxItems, maxLength, maxValue, mimeTypeLookup, minDate, minItems, minLength, minUrlLength, minValue, monthTranslationKeyOrder, multiValidation, nameof, nanasFonts, noValidation, notNull, onlyUnique, portalGlyphLength, promiseFromValue, randomIntFromRange, randomItemFromArray, rootContainer, rootDependencyInjectionSetup, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, setContainerToken, setContainerTokenLazy, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, showSecondCalendar, socialLinks, timeout, tryParseNumber, uploadsThatNeedEncryption, urlRef, uuidv4, validUuidChars, validateForEach, webAppTypes, weekdayTranslationKeyOrder };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'problem',
|
|
4
|
+
docs: {
|
|
5
|
+
description: 'Require at least one data-debug attribute or <DebugNode> component in TSX files',
|
|
6
|
+
},
|
|
7
|
+
schema: [],
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
create(context) {
|
|
11
|
+
const filename = context.filename;
|
|
12
|
+
if (filename.endsWith('.ts')) return {};
|
|
13
|
+
if (filename.endsWith('.meta.tsx')) return {};
|
|
14
|
+
|
|
15
|
+
let found = false;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
JSXAttribute(node) {
|
|
19
|
+
if (node.name?.name === 'data-debug') found = true;
|
|
20
|
+
if (node.name?.name === 'debug') found = true;
|
|
21
|
+
},
|
|
22
|
+
JSXOpeningElement(node) {
|
|
23
|
+
if (node.name?.type === 'JSXIdentifier' && node.name.name === 'DebugNode') {
|
|
24
|
+
found = true;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'Program:exit'() {
|
|
28
|
+
if (!found) {
|
|
29
|
+
context.report({
|
|
30
|
+
loc: { line: 1, column: 0 },
|
|
31
|
+
message: 'TSX file must contain at least one `data-debug` attribute or `<DebugNode>` component.',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|