@elliemae/ds-codemods 3.37.0-rc.1 → 3.37.0-rc.3
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.
|
@@ -46,6 +46,14 @@ import {
|
|
|
46
46
|
*
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
+
const subStringAdhocDSMatcher = (str, substr) => {
|
|
50
|
+
if (str === substr) return true;
|
|
51
|
+
const substrRegExp = substr.startsWith('@elliemae/ds-')
|
|
52
|
+
? new RegExp(`@\\belliemae\/ds-${substr.split('@elliemae/ds-')[1]}`, 'g')
|
|
53
|
+
: new RegExp(`\\b${substr}\\b`, 'g');
|
|
54
|
+
return str.match(substrRegExp) !== null;
|
|
55
|
+
};
|
|
56
|
+
|
|
49
57
|
// we generate some supporting data structures to make the matching more efficient from the existing constants...
|
|
50
58
|
// we do this runtime because we want to avoid having to maintain this manually and this is a one time cost runtime wise with the cache...
|
|
51
59
|
const runtimeDeprecatedDSReportCache = new Map();
|
|
@@ -93,19 +101,18 @@ const checkDeprecatedEffort = (importStatements, deprecatedEffortMap, effortCach
|
|
|
93
101
|
importStatements.forEach((importStatement) => {
|
|
94
102
|
const [fullMatch, importedComponent, packageName] = importStatement;
|
|
95
103
|
// first we check if we need to care about this package at all
|
|
96
|
-
// we do not care if the package is not in the list of packages that
|
|
97
|
-
// when the
|
|
104
|
+
// we do not care if the package is not in the list of packages that are deprecated
|
|
105
|
+
// when the deprecated component and live components lives in different packages we know for sure that the statement is deprecated
|
|
98
106
|
const statementIsDeprecatedForSure =
|
|
99
|
-
effortsDifferentPackageList.findIndex((pck) => pck
|
|
100
|
-
// when the
|
|
107
|
+
effortsDifferentPackageList.findIndex((pck) => subStringAdhocDSMatcher(pck, packageName)) !== -1;
|
|
108
|
+
// when the new and old lives under the same package (E.G. tooltip -> tooltipv3 from ds-tooltip, buttonv2 -> buttonv3 from ds-button-v2 ...)
|
|
109
|
+
// we need to check if the component itself is deprecated or not, just the "from ..." part is not enough
|
|
101
110
|
const statementIsPotentiallyDeprecated =
|
|
102
|
-
effortsSamePackageList.findIndex((pck) => pck
|
|
111
|
+
effortsSamePackageList.findIndex((pck) => subStringAdhocDSMatcher(pck, packageName)) !== -1;
|
|
103
112
|
let isStatementActuallyDeprecated = false;
|
|
104
113
|
if (!statementIsDeprecatedForSure && statementIsPotentiallyDeprecated) {
|
|
105
114
|
effortsSamePackageOldComponentsList.forEach((deprecatedComponent) => {
|
|
106
|
-
if (importedComponent
|
|
107
|
-
isStatementActuallyDeprecated = true;
|
|
108
|
-
}
|
|
115
|
+
if (subStringAdhocDSMatcher(importedComponent, deprecatedComponent)) isStatementActuallyDeprecated = true;
|
|
109
116
|
});
|
|
110
117
|
}
|
|
111
118
|
const statementIsDeprecated = statementIsDeprecatedForSure || isStatementActuallyDeprecated;
|
|
@@ -114,7 +121,7 @@ const checkDeprecatedEffort = (importStatements, deprecatedEffortMap, effortCach
|
|
|
114
121
|
// we do this so we can reach the constant meta-informations (like the new package name, severityTags, etc...)
|
|
115
122
|
// technically this is O(n * m) where n is ~<10 and m is ~<50 so even the worst case is not that bad...
|
|
116
123
|
const matchingEffortMetainfoIndx = deprecatedEffortMap.findIndex((effortMetainfo) =>
|
|
117
|
-
importedComponent
|
|
124
|
+
subStringAdhocDSMatcher(importedComponent, effortMetainfo.component),
|
|
118
125
|
);
|
|
119
126
|
if (matchingEffortMetainfoIndx === -1) return;
|
|
120
127
|
matchedEfforts.set(fullMatch, {
|
|
@@ -158,8 +165,11 @@ export const checkDeprecatedDismissed = (importStatements) => {
|
|
|
158
165
|
const matchedEfforts = new Map();
|
|
159
166
|
importStatements.forEach((importStatement) => {
|
|
160
167
|
const [fullMatch, importedComponent, packageName] = importStatement;
|
|
161
|
-
const matchingEffortMetainfoIndx = DISMISSED_WITH_EXAMPLE.findIndex(
|
|
162
|
-
|
|
168
|
+
const matchingEffortMetainfoIndx = DISMISSED_WITH_EXAMPLE.findIndex(
|
|
169
|
+
(effortMetainfo) =>
|
|
170
|
+
subStringAdhocDSMatcher(importedComponent, effortMetainfo.component) &&
|
|
171
|
+
// {DSGroupBox} from 'ds-mobile' is not (yet) deprecated, DSGroupBox is a repeated component name, we need the extra package check
|
|
172
|
+
subStringAdhocDSMatcher(packageName, effortMetainfo.oldPackage),
|
|
163
173
|
);
|
|
164
174
|
if (matchingEffortMetainfoIndx === -1) return;
|
|
165
175
|
matchedEfforts.set(fullMatch, {
|