@memberjunction/react-test-harness 2.97.0 ā 2.98.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/lib/component-linter.d.ts.map +1 -1
- package/dist/lib/component-linter.js +55 -12
- package/dist/lib/component-linter.js.map +1 -1
- package/dist/lib/component-runner.d.ts +0 -1
- package/dist/lib/component-runner.d.ts.map +1 -1
- package/dist/lib/component-runner.js +258 -40
- package/dist/lib/component-runner.js.map +1 -1
- package/dist/lib/library-lint-cache.d.ts +4 -0
- package/dist/lib/library-lint-cache.d.ts.map +1 -1
- package/dist/lib/library-lint-cache.js +61 -3
- package/dist/lib/library-lint-cache.js.map +1 -1
- package/dist/lib/test-harness.d.ts.map +1 -1
- package/dist/lib/test-harness.js +5 -2
- package/dist/lib/test-harness.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-linter.d.ts","sourceRoot":"","sources":["../../src/lib/component-linter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAiC,MAAM,6CAA6C,CAAC;AAG3G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,GAAG,M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aAAa,CAAC,EAAE,aAAa,EAC7B,eAAe,CAAC,EAAE,OAAO,EACzB,WAAW,CAAC,EAAE,QAAQ,EACtB,SAAS,CAAC,EAAE,OAAO,EACnB,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,UAAU,CAAC;IAqJtB,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAoXvC,OAAO,CAAC,MAAM,CAAC,eAAe;IA2B9B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAyBpC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAmiCzC,OAAO,CAAC,MAAM,CAAC,8BAA8B;IA2B7C;;OAEG;mBACkB,qBAAqB;IAuJ1C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAiEzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA8ClC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IA8GpC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAoElC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;CAkGzC"}
|
|
@@ -196,6 +196,10 @@ class ComponentLinter {
|
|
|
196
196
|
}
|
|
197
197
|
static async lintComponent(code, componentName, componentSpec, isRootComponent, contextUser, debugMode, options) {
|
|
198
198
|
try {
|
|
199
|
+
// Require contextUser when libraries need to be checked
|
|
200
|
+
if (componentSpec?.libraries && componentSpec.libraries.length > 0 && !contextUser) {
|
|
201
|
+
throw new Error('contextUser is required when linting components with library dependencies. This is needed to load library-specific lint rules from the database.');
|
|
202
|
+
}
|
|
199
203
|
// Parse with error recovery to get both AST and errors
|
|
200
204
|
const parseResult = parser.parse(code, {
|
|
201
205
|
sourceType: 'module',
|
|
@@ -259,7 +263,7 @@ class ComponentLinter {
|
|
|
259
263
|
violations.push(...dataViolations);
|
|
260
264
|
}
|
|
261
265
|
// Apply library-specific lint rules if available
|
|
262
|
-
if (componentSpec?.libraries
|
|
266
|
+
if (componentSpec?.libraries) {
|
|
263
267
|
const libraryViolations = await this.applyLibraryLintRules(ast, componentSpec, contextUser, debugMode);
|
|
264
268
|
violations.push(...libraryViolations);
|
|
265
269
|
}
|
|
@@ -1762,50 +1766,78 @@ const {
|
|
|
1762
1766
|
const libraryViolations = [];
|
|
1763
1767
|
// Get the cached and compiled rules for this library
|
|
1764
1768
|
const compiledRules = cache.getLibraryRules(lib.name);
|
|
1769
|
+
if (debugMode) {
|
|
1770
|
+
console.log(`\n š Library: ${lib.name}`);
|
|
1771
|
+
if (compiledRules) {
|
|
1772
|
+
console.log(` āā Has lint rules: ā
`);
|
|
1773
|
+
if (compiledRules.validators) {
|
|
1774
|
+
console.log(` āā Validators: ${Object.keys(compiledRules.validators).length}`);
|
|
1775
|
+
}
|
|
1776
|
+
if (compiledRules.initialization) {
|
|
1777
|
+
console.log(` āā Initialization rules: ā
`);
|
|
1778
|
+
}
|
|
1779
|
+
if (compiledRules.lifecycle) {
|
|
1780
|
+
console.log(` āā Lifecycle rules: ā
`);
|
|
1781
|
+
}
|
|
1782
|
+
console.log(` āā Starting checks...`);
|
|
1783
|
+
}
|
|
1784
|
+
else {
|
|
1785
|
+
console.log(` āā No lint rules defined`);
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1765
1788
|
if (compiledRules) {
|
|
1766
1789
|
const library = compiledRules.library;
|
|
1767
1790
|
const libraryName = library.Name || lib.name;
|
|
1768
1791
|
// Apply initialization rules
|
|
1769
1792
|
if (compiledRules.initialization) {
|
|
1793
|
+
if (debugMode) {
|
|
1794
|
+
console.log(` āā š Checking ${libraryName} initialization patterns...`);
|
|
1795
|
+
}
|
|
1770
1796
|
const initViolations = this.checkLibraryInitialization(ast, libraryName, compiledRules.initialization);
|
|
1771
1797
|
// Debug logging for library violations
|
|
1772
1798
|
if (debugMode && initViolations.length > 0) {
|
|
1773
|
-
console.log(
|
|
1799
|
+
console.log(` ā ā ļø Found ${initViolations.length} initialization issue${initViolations.length > 1 ? 's' : ''}`);
|
|
1774
1800
|
initViolations.forEach(v => {
|
|
1775
1801
|
const icon = v.severity === 'critical' ? 'š“' :
|
|
1776
1802
|
v.severity === 'high' ? 'š ' :
|
|
1777
1803
|
v.severity === 'medium' ? 'š”' : 'š¢';
|
|
1778
|
-
console.log(` ${icon}
|
|
1804
|
+
console.log(` ā ${icon} Line ${v.line}: ${v.message}`);
|
|
1779
1805
|
});
|
|
1780
1806
|
}
|
|
1781
1807
|
libraryViolations.push(...initViolations);
|
|
1782
1808
|
}
|
|
1783
1809
|
// Apply lifecycle rules
|
|
1784
1810
|
if (compiledRules.lifecycle) {
|
|
1811
|
+
if (debugMode) {
|
|
1812
|
+
console.log(` āā š Checking ${libraryName} lifecycle management...`);
|
|
1813
|
+
}
|
|
1785
1814
|
const lifecycleViolations = this.checkLibraryLifecycle(ast, libraryName, compiledRules.lifecycle);
|
|
1786
1815
|
// Debug logging for library violations
|
|
1787
1816
|
if (debugMode && lifecycleViolations.length > 0) {
|
|
1788
|
-
console.log(
|
|
1817
|
+
console.log(` ā ā ļø Found ${lifecycleViolations.length} lifecycle issue${lifecycleViolations.length > 1 ? 's' : ''}`);
|
|
1789
1818
|
lifecycleViolations.forEach(v => {
|
|
1790
1819
|
const icon = v.severity === 'critical' ? 'š“' :
|
|
1791
1820
|
v.severity === 'high' ? 'š ' :
|
|
1792
1821
|
v.severity === 'medium' ? 'š”' : 'š¢';
|
|
1793
|
-
console.log(` ${icon}
|
|
1822
|
+
console.log(` ā ${icon} Line ${v.line}: ${v.message}`);
|
|
1794
1823
|
});
|
|
1795
1824
|
}
|
|
1796
1825
|
libraryViolations.push(...lifecycleViolations);
|
|
1797
1826
|
}
|
|
1798
1827
|
// Apply options validation
|
|
1799
1828
|
if (compiledRules.options) {
|
|
1829
|
+
if (debugMode) {
|
|
1830
|
+
console.log(` āā āļø Checking ${libraryName} configuration options...`);
|
|
1831
|
+
}
|
|
1800
1832
|
const optionsViolations = this.checkLibraryOptions(ast, libraryName, compiledRules.options);
|
|
1801
1833
|
// Debug logging for library violations
|
|
1802
1834
|
if (debugMode && optionsViolations.length > 0) {
|
|
1803
|
-
console.log(
|
|
1835
|
+
console.log(` ā ā ļø Found ${optionsViolations.length} configuration issue${optionsViolations.length > 1 ? 's' : ''}`);
|
|
1804
1836
|
optionsViolations.forEach(v => {
|
|
1805
1837
|
const icon = v.severity === 'critical' ? 'š“' :
|
|
1806
1838
|
v.severity === 'high' ? 'š ' :
|
|
1807
1839
|
v.severity === 'medium' ? 'š”' : 'š¢';
|
|
1808
|
-
console.log(` ${icon}
|
|
1840
|
+
console.log(` ā ${icon} Line ${v.line}: ${v.message}`);
|
|
1809
1841
|
});
|
|
1810
1842
|
}
|
|
1811
1843
|
libraryViolations.push(...optionsViolations);
|
|
@@ -2105,6 +2137,13 @@ const {
|
|
|
2105
2137
|
for (const [validatorName, validator] of Object.entries(validators)) {
|
|
2106
2138
|
if (validator && validator.validateFn) {
|
|
2107
2139
|
const beforeCount = context.violations.length;
|
|
2140
|
+
// Log that we're running this specific validator
|
|
2141
|
+
if (debugMode) {
|
|
2142
|
+
console.log(` āā š¬ Running ${libraryName} validator: ${validatorName}`);
|
|
2143
|
+
if (validator.description) {
|
|
2144
|
+
console.log(` ā ā¹ļø ${validator.description}`);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2108
2147
|
// Traverse AST and apply validator
|
|
2109
2148
|
(0, traverse_1.default)(ast, {
|
|
2110
2149
|
enter(path) {
|
|
@@ -2115,27 +2154,31 @@ const {
|
|
|
2115
2154
|
catch (error) {
|
|
2116
2155
|
// Validator execution error - log but don't crash
|
|
2117
2156
|
console.warn(`Validator ${validatorName} failed:`, error);
|
|
2157
|
+
if (debugMode) {
|
|
2158
|
+
console.error('Full error:', error);
|
|
2159
|
+
}
|
|
2118
2160
|
}
|
|
2119
2161
|
}
|
|
2120
2162
|
});
|
|
2121
2163
|
// Debug logging for this specific validator
|
|
2122
2164
|
const newViolations = context.violations.length - beforeCount;
|
|
2123
2165
|
if (debugMode && newViolations > 0) {
|
|
2124
|
-
console.log(
|
|
2125
|
-
console.log(` š ${validator.description || 'No description'}`);
|
|
2126
|
-
console.log(` ā ļø Found ${newViolations} violation${newViolations > 1 ? 's' : ''}`);
|
|
2166
|
+
console.log(` ā ā Found ${newViolations} violation${newViolations > 1 ? 's' : ''}`);
|
|
2127
2167
|
// Show the violations from this validator
|
|
2128
2168
|
const validatorViolations = context.violations.slice(beforeCount);
|
|
2129
2169
|
validatorViolations.forEach((v) => {
|
|
2130
2170
|
const icon = v.type === 'error' || v.severity === 'critical' ? 'š“' :
|
|
2131
2171
|
v.type === 'warning' || v.severity === 'high' ? 'š ' :
|
|
2132
2172
|
v.severity === 'medium' ? 'š”' : 'š¢';
|
|
2133
|
-
console.log(`
|
|
2173
|
+
console.log(` ā ${icon} Line ${v.line || 'unknown'}: ${v.message}`);
|
|
2134
2174
|
if (v.suggestion) {
|
|
2135
|
-
console.log(`
|
|
2175
|
+
console.log(` ā š” ${v.suggestion}`);
|
|
2136
2176
|
}
|
|
2137
2177
|
});
|
|
2138
2178
|
}
|
|
2179
|
+
else if (debugMode) {
|
|
2180
|
+
console.log(` ā ā No violations found`);
|
|
2181
|
+
}
|
|
2139
2182
|
}
|
|
2140
2183
|
}
|
|
2141
2184
|
// Convert context violations to standard format
|