@elliemae/ds-codemods 3.37.0-rc.1 → 3.37.0-rc.2
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,11 @@ import {
|
|
|
46
46
|
*
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
+
const strStrictIncludes = (str, substr) => {
|
|
50
|
+
const substrRegExp = new RegExp(`\\b${substr}\\b`, 'g');
|
|
51
|
+
return str.match(substrRegExp) !== null;
|
|
52
|
+
};
|
|
53
|
+
|
|
49
54
|
// we generate some supporting data structures to make the matching more efficient from the existing constants...
|
|
50
55
|
// 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
56
|
const runtimeDeprecatedDSReportCache = new Map();
|
|
@@ -96,16 +101,15 @@ const checkDeprecatedEffort = (importStatements, deprecatedEffortMap, effortCach
|
|
|
96
101
|
// we do not care if the package is not in the list of packages that have small migration effort
|
|
97
102
|
// when the deprecation is in another package we know for sure that the statement is deprecated
|
|
98
103
|
const statementIsDeprecatedForSure =
|
|
99
|
-
effortsDifferentPackageList.findIndex((pck) => pck
|
|
104
|
+
effortsDifferentPackageList.findIndex((pck) => strStrictIncludes(pck, packageName)) !== -1;
|
|
100
105
|
// when the deprecation is in the same package we need to check if the component itself is deprecated
|
|
101
106
|
const statementIsPotentiallyDeprecated =
|
|
102
|
-
effortsSamePackageList.findIndex((pck) => pck
|
|
107
|
+
effortsSamePackageList.findIndex((pck) => strStrictIncludes(pck, packageName)) !== -1;
|
|
103
108
|
let isStatementActuallyDeprecated = false;
|
|
104
109
|
if (!statementIsDeprecatedForSure && statementIsPotentiallyDeprecated) {
|
|
105
110
|
effortsSamePackageOldComponentsList.forEach((deprecatedComponent) => {
|
|
106
|
-
if (importedComponent
|
|
107
|
-
|
|
108
|
-
}
|
|
111
|
+
if (strStrictIncludes(importedComponent, deprecatedComponent)) return;
|
|
112
|
+
isStatementActuallyDeprecated = true;
|
|
109
113
|
});
|
|
110
114
|
}
|
|
111
115
|
const statementIsDeprecated = statementIsDeprecatedForSure || isStatementActuallyDeprecated;
|
|
@@ -114,7 +118,7 @@ const checkDeprecatedEffort = (importStatements, deprecatedEffortMap, effortCach
|
|
|
114
118
|
// we do this so we can reach the constant meta-informations (like the new package name, severityTags, etc...)
|
|
115
119
|
// technically this is O(n * m) where n is ~<10 and m is ~<50 so even the worst case is not that bad...
|
|
116
120
|
const matchingEffortMetainfoIndx = deprecatedEffortMap.findIndex((effortMetainfo) =>
|
|
117
|
-
importedComponent
|
|
121
|
+
strStrictIncludes(importedComponent, effortMetainfo.component),
|
|
118
122
|
);
|
|
119
123
|
if (matchingEffortMetainfoIndx === -1) return;
|
|
120
124
|
matchedEfforts.set(fullMatch, {
|
|
@@ -159,7 +163,7 @@ export const checkDeprecatedDismissed = (importStatements) => {
|
|
|
159
163
|
importStatements.forEach((importStatement) => {
|
|
160
164
|
const [fullMatch, importedComponent, packageName] = importStatement;
|
|
161
165
|
const matchingEffortMetainfoIndx = DISMISSED_WITH_EXAMPLE.findIndex((effortMetainfo) =>
|
|
162
|
-
importedComponent
|
|
166
|
+
strStrictIncludes(importedComponent, effortMetainfo.component),
|
|
163
167
|
);
|
|
164
168
|
if (matchingEffortMetainfoIndx === -1) return;
|
|
165
169
|
matchedEfforts.set(fullMatch, {
|