@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.4
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/README.md +44 -54
- package/bin/cli.js +1 -115
- package/bin/loxia-terminal-v2.js +3 -0
- package/bin/loxia-terminal.js +3 -0
- package/bin/start-with-terminal.js +3 -0
- package/package.json +15 -15
- package/scripts/install-scanners.js +1 -235
- package/src/analyzers/CSSAnalyzer.js +1 -297
- package/src/analyzers/ConfigValidator.js +1 -690
- package/src/analyzers/ESLintAnalyzer.js +1 -320
- package/src/analyzers/JavaScriptAnalyzer.js +1 -261
- package/src/analyzers/PrettierFormatter.js +1 -247
- package/src/analyzers/PythonAnalyzer.js +1 -266
- package/src/analyzers/SecurityAnalyzer.js +1 -729
- package/src/analyzers/TypeScriptAnalyzer.js +1 -247
- package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
- package/src/analyzers/codeCloneDetector/detector.js +1 -203
- package/src/analyzers/codeCloneDetector/index.js +1 -160
- package/src/analyzers/codeCloneDetector/parser.js +1 -199
- package/src/analyzers/codeCloneDetector/reporter.js +1 -148
- package/src/analyzers/codeCloneDetector/scanner.js +1 -59
- package/src/core/agentPool.js +1 -1474
- package/src/core/agentScheduler.js +1 -2147
- package/src/core/contextManager.js +1 -709
- package/src/core/messageProcessor.js +1 -732
- package/src/core/orchestrator.js +1 -548
- package/src/core/stateManager.js +1 -877
- package/src/index.js +1 -631
- package/src/interfaces/cli.js +1 -549
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
- package/src/interfaces/terminal/api/apiClient.js +1 -0
- package/src/interfaces/terminal/api/messageRouter.js +1 -0
- package/src/interfaces/terminal/api/session.js +1 -0
- package/src/interfaces/terminal/api/websocket.js +1 -0
- package/src/interfaces/terminal/components/AgentCreator.js +1 -0
- package/src/interfaces/terminal/components/AgentEditor.js +1 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
- package/src/interfaces/terminal/components/Header.js +1 -0
- package/src/interfaces/terminal/components/HelpPanel.js +1 -0
- package/src/interfaces/terminal/components/InputBox.js +1 -0
- package/src/interfaces/terminal/components/Layout.js +1 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
- package/src/interfaces/terminal/components/MessageList.js +1 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
- package/src/interfaces/terminal/components/SearchPanel.js +1 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
- package/src/interfaces/terminal/components/StatusBar.js +1 -0
- package/src/interfaces/terminal/components/TextInput.js +1 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
- package/src/interfaces/terminal/config/constants.js +1 -0
- package/src/interfaces/terminal/index.js +1 -0
- package/src/interfaces/terminal/state/useAgentControl.js +1 -0
- package/src/interfaces/terminal/state/useAgents.js +1 -0
- package/src/interfaces/terminal/state/useConnection.js +1 -0
- package/src/interfaces/terminal/state/useMessages.js +1 -0
- package/src/interfaces/terminal/state/useTools.js +1 -0
- package/src/interfaces/terminal/utils/debugLogger.js +1 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
- package/src/interfaces/terminal/utils/theme.js +1 -0
- package/src/interfaces/webServer.js +1 -2162
- package/src/modules/fileExplorer/controller.js +1 -280
- package/src/modules/fileExplorer/index.js +1 -37
- package/src/modules/fileExplorer/middleware.js +1 -92
- package/src/modules/fileExplorer/routes.js +1 -125
- package/src/modules/fileExplorer/types.js +1 -44
- package/src/services/aiService.js +1 -1232
- package/src/services/apiKeyManager.js +1 -164
- package/src/services/benchmarkService.js +1 -366
- package/src/services/budgetService.js +1 -539
- package/src/services/contextInjectionService.js +1 -247
- package/src/services/conversationCompactionService.js +1 -637
- package/src/services/errorHandler.js +1 -810
- package/src/services/fileAttachmentService.js +1 -544
- package/src/services/modelRouterService.js +1 -366
- package/src/services/modelsService.js +1 -322
- package/src/services/qualityInspector.js +1 -796
- package/src/services/tokenCountingService.js +1 -536
- package/src/tools/agentCommunicationTool.js +1 -1344
- package/src/tools/agentDelayTool.js +1 -485
- package/src/tools/asyncToolManager.js +1 -604
- package/src/tools/baseTool.js +1 -800
- package/src/tools/browserTool.js +1 -920
- package/src/tools/cloneDetectionTool.js +1 -621
- package/src/tools/dependencyResolverTool.js +1 -1215
- package/src/tools/fileContentReplaceTool.js +1 -875
- package/src/tools/fileSystemTool.js +1 -1107
- package/src/tools/fileTreeTool.js +1 -853
- package/src/tools/imageTool.js +1 -901
- package/src/tools/importAnalyzerTool.js +1 -1060
- package/src/tools/jobDoneTool.js +1 -248
- package/src/tools/seekTool.js +1 -956
- package/src/tools/staticAnalysisTool.js +1 -1778
- package/src/tools/taskManagerTool.js +1 -2873
- package/src/tools/terminalTool.js +1 -2304
- package/src/tools/webTool.js +1 -1430
- package/src/types/agent.js +1 -519
- package/src/types/contextReference.js +1 -972
- package/src/types/conversation.js +1 -730
- package/src/types/toolCommand.js +1 -747
- package/src/utilities/attachmentValidator.js +1 -292
- package/src/utilities/configManager.js +1 -582
- package/src/utilities/constants.js +1 -722
- package/src/utilities/directoryAccessManager.js +1 -535
- package/src/utilities/fileProcessor.js +1 -307
- package/src/utilities/logger.js +1 -436
- package/src/utilities/tagParser.js +1 -1246
- package/src/utilities/toolConstants.js +1 -317
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
- package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
|
@@ -1,320 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* ESLintAnalyzer - JavaScript/TypeScript code style analysis using ESLint
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Analyze code style and quality issues
|
|
6
|
-
* - Detect best practice violations
|
|
7
|
-
* - Support auto-fix for fixable issues
|
|
8
|
-
* - Integration with popular ESLint configurations
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { ESLint } from 'eslint';
|
|
12
|
-
import path from 'path';
|
|
13
|
-
import fs from 'fs/promises';
|
|
14
|
-
import { STATIC_ANALYSIS } from '../utilities/constants.js';
|
|
15
|
-
|
|
16
|
-
class ESLintAnalyzer {
|
|
17
|
-
constructor(logger = null) {
|
|
18
|
-
this.logger = logger;
|
|
19
|
-
this.eslintCache = new Map();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Analyze code with ESLint
|
|
24
|
-
* @param {string} filePath - Path to file
|
|
25
|
-
* @param {string} content - File content
|
|
26
|
-
* @param {Object} options - Analysis options
|
|
27
|
-
* @returns {Promise<Array>} Array of diagnostics
|
|
28
|
-
*/
|
|
29
|
-
async analyze(filePath, content, options = {}) {
|
|
30
|
-
try {
|
|
31
|
-
const eslint = await this.getESLintInstance(options);
|
|
32
|
-
|
|
33
|
-
// Analyze the code
|
|
34
|
-
const results = await eslint.lintText(content, {
|
|
35
|
-
filePath,
|
|
36
|
-
warnIgnored: false
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Format results
|
|
40
|
-
const diagnostics = [];
|
|
41
|
-
|
|
42
|
-
if (results && results.length > 0) {
|
|
43
|
-
const result = results[0];
|
|
44
|
-
|
|
45
|
-
for (const message of result.messages) {
|
|
46
|
-
diagnostics.push(this.formatMessage(message, filePath));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
this.logger?.debug('ESLint analysis completed', {
|
|
51
|
-
file: filePath,
|
|
52
|
-
totalDiagnostics: diagnostics.length,
|
|
53
|
-
errors: diagnostics.filter(d => d.severity === STATIC_ANALYSIS.SEVERITY.ERROR).length,
|
|
54
|
-
warnings: diagnostics.filter(d => d.severity === STATIC_ANALYSIS.SEVERITY.WARNING).length
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return diagnostics;
|
|
58
|
-
|
|
59
|
-
} catch (error) {
|
|
60
|
-
this.logger?.error('ESLint analysis failed', {
|
|
61
|
-
file: filePath,
|
|
62
|
-
error: error.message
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Return empty array on error to allow TypeScript analyzer to continue
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Auto-fix code issues
|
|
72
|
-
* @param {string} filePath - Path to file
|
|
73
|
-
* @param {string} content - File content
|
|
74
|
-
* @param {Object} options - Fix options
|
|
75
|
-
* @returns {Promise<Object>} Fixed content and changes
|
|
76
|
-
*/
|
|
77
|
-
async fix(filePath, content, options = {}) {
|
|
78
|
-
try {
|
|
79
|
-
const eslint = await this.getESLintInstance({
|
|
80
|
-
...options,
|
|
81
|
-
fix: true // Enable auto-fix
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Fix the code
|
|
85
|
-
const results = await eslint.lintText(content, {
|
|
86
|
-
filePath,
|
|
87
|
-
warnIgnored: false
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
if (results && results.length > 0) {
|
|
91
|
-
const result = results[0];
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
fixed: result.output !== undefined,
|
|
95
|
-
content: result.output || content,
|
|
96
|
-
fixedCount: result.fixableErrorCount + result.fixableWarningCount,
|
|
97
|
-
remainingErrors: result.errorCount - result.fixableErrorCount,
|
|
98
|
-
remainingWarnings: result.warningCount - result.fixableWarningCount,
|
|
99
|
-
changes: result.output ? this.describeChanges(content, result.output) : []
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
fixed: false,
|
|
105
|
-
content,
|
|
106
|
-
fixedCount: 0,
|
|
107
|
-
remainingErrors: 0,
|
|
108
|
-
remainingWarnings: 0,
|
|
109
|
-
changes: []
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
} catch (error) {
|
|
113
|
-
this.logger?.error('ESLint fix failed', {
|
|
114
|
-
file: filePath,
|
|
115
|
-
error: error.message
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
throw new Error(`ESLint fix failed: ${error.message}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Get or create ESLint instance
|
|
124
|
-
* @private
|
|
125
|
-
*/
|
|
126
|
-
async getESLintInstance(options = {}) {
|
|
127
|
-
const {
|
|
128
|
-
workingDir,
|
|
129
|
-
fix = false,
|
|
130
|
-
framework
|
|
131
|
-
} = options;
|
|
132
|
-
|
|
133
|
-
// Create ESLint instance with configuration
|
|
134
|
-
const eslintConfig = await this.getESLintConfig(workingDir, framework);
|
|
135
|
-
|
|
136
|
-
const eslint = new ESLint({
|
|
137
|
-
fix,
|
|
138
|
-
useEslintrc: true, // Use .eslintrc if available
|
|
139
|
-
overrideConfig: eslintConfig,
|
|
140
|
-
errorOnUnmatchedPattern: false
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
return eslint;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Get ESLint configuration
|
|
148
|
-
* @private
|
|
149
|
-
*/
|
|
150
|
-
async getESLintConfig(workingDir, framework) {
|
|
151
|
-
// Base configuration
|
|
152
|
-
const config = {
|
|
153
|
-
env: {
|
|
154
|
-
browser: true,
|
|
155
|
-
es2021: true,
|
|
156
|
-
node: true
|
|
157
|
-
},
|
|
158
|
-
parserOptions: {
|
|
159
|
-
ecmaVersion: 'latest',
|
|
160
|
-
sourceType: 'module'
|
|
161
|
-
},
|
|
162
|
-
rules: {
|
|
163
|
-
// Common rules
|
|
164
|
-
'no-unused-vars': 'warn',
|
|
165
|
-
'no-undef': 'error',
|
|
166
|
-
'no-console': 'off',
|
|
167
|
-
'semi': ['warn', 'always'],
|
|
168
|
-
'quotes': ['warn', 'single', { avoidEscape: true }]
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// Framework-specific configurations
|
|
173
|
-
if (framework === 'react') {
|
|
174
|
-
config.extends = ['eslint:recommended'];
|
|
175
|
-
config.parserOptions.ecmaFeatures = { jsx: true };
|
|
176
|
-
config.settings = {
|
|
177
|
-
react: {
|
|
178
|
-
version: 'detect'
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
} else if (framework === 'vue') {
|
|
182
|
-
config.extends = ['eslint:recommended'];
|
|
183
|
-
} else {
|
|
184
|
-
config.extends = ['eslint:recommended'];
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Try to detect and use project's ESLint config
|
|
188
|
-
if (workingDir) {
|
|
189
|
-
const configFiles = [
|
|
190
|
-
'.eslintrc.js',
|
|
191
|
-
'.eslintrc.cjs',
|
|
192
|
-
'.eslintrc.json',
|
|
193
|
-
'eslint.config.js'
|
|
194
|
-
];
|
|
195
|
-
|
|
196
|
-
for (const configFile of configFiles) {
|
|
197
|
-
try {
|
|
198
|
-
const configPath = path.join(workingDir, configFile);
|
|
199
|
-
await fs.access(configPath);
|
|
200
|
-
this.logger?.debug('Found ESLint config', { configFile });
|
|
201
|
-
// If config exists, let ESLint use it via useEslintrc
|
|
202
|
-
return {}; // Return empty config to let ESLint use the file
|
|
203
|
-
} catch {
|
|
204
|
-
// Config file doesn't exist, continue
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return config;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Format ESLint message to standard diagnostic format
|
|
214
|
-
* @private
|
|
215
|
-
*/
|
|
216
|
-
formatMessage(message, filePath) {
|
|
217
|
-
return {
|
|
218
|
-
file: filePath,
|
|
219
|
-
line: message.line || 1,
|
|
220
|
-
column: message.column || 1,
|
|
221
|
-
endLine: message.endLine,
|
|
222
|
-
endColumn: message.endColumn,
|
|
223
|
-
severity: message.severity === 2
|
|
224
|
-
? STATIC_ANALYSIS.SEVERITY.ERROR
|
|
225
|
-
: STATIC_ANALYSIS.SEVERITY.WARNING,
|
|
226
|
-
rule: message.ruleId || 'eslint',
|
|
227
|
-
message: message.message,
|
|
228
|
-
category: this.categorizeRule(message.ruleId),
|
|
229
|
-
fixable: message.fix !== undefined,
|
|
230
|
-
source: 'eslint'
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Categorize ESLint rule into error category
|
|
236
|
-
* @private
|
|
237
|
-
*/
|
|
238
|
-
categorizeRule(ruleId) {
|
|
239
|
-
if (!ruleId) return STATIC_ANALYSIS.CATEGORY.STYLE;
|
|
240
|
-
|
|
241
|
-
// Security rules
|
|
242
|
-
if (ruleId.includes('security') ||
|
|
243
|
-
ruleId.includes('xss') ||
|
|
244
|
-
ruleId === 'no-eval' ||
|
|
245
|
-
ruleId === 'no-implied-eval') {
|
|
246
|
-
return STATIC_ANALYSIS.CATEGORY.SECURITY;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Performance rules
|
|
250
|
-
if (ruleId.includes('performance') ||
|
|
251
|
-
ruleId === 'no-await-in-loop' ||
|
|
252
|
-
ruleId === 'prefer-promise-reject-errors') {
|
|
253
|
-
return STATIC_ANALYSIS.CATEGORY.PERFORMANCE;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Import rules
|
|
257
|
-
if (ruleId.includes('import') ||
|
|
258
|
-
ruleId === 'no-undef') {
|
|
259
|
-
return STATIC_ANALYSIS.CATEGORY.IMPORT;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Best practice rules
|
|
263
|
-
if (ruleId.includes('best-practices') ||
|
|
264
|
-
ruleId === 'no-unused-vars' ||
|
|
265
|
-
ruleId === 'no-unreachable' ||
|
|
266
|
-
ruleId === 'no-var') {
|
|
267
|
-
return STATIC_ANALYSIS.CATEGORY.BEST_PRACTICE;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Default to style
|
|
271
|
-
return STATIC_ANALYSIS.CATEGORY.STYLE;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Describe changes made by auto-fix
|
|
276
|
-
* @private
|
|
277
|
-
*/
|
|
278
|
-
describeChanges(original, fixed) {
|
|
279
|
-
const changes = [];
|
|
280
|
-
const originalLines = original.split('\n');
|
|
281
|
-
const fixedLines = fixed.split('\n');
|
|
282
|
-
|
|
283
|
-
// Simple diff - compare line by line
|
|
284
|
-
const maxLines = Math.max(originalLines.length, fixedLines.length);
|
|
285
|
-
|
|
286
|
-
for (let i = 0; i < maxLines; i++) {
|
|
287
|
-
const origLine = originalLines[i] || '';
|
|
288
|
-
const fixedLine = fixedLines[i] || '';
|
|
289
|
-
|
|
290
|
-
if (origLine !== fixedLine) {
|
|
291
|
-
changes.push({
|
|
292
|
-
line: i + 1,
|
|
293
|
-
type: origLine && fixedLine ? 'modified' : (origLine ? 'removed' : 'added'),
|
|
294
|
-
original: origLine,
|
|
295
|
-
fixed: fixedLine
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return changes;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Get supported file extensions
|
|
305
|
-
* @returns {Array<string>} Array of supported extensions
|
|
306
|
-
*/
|
|
307
|
-
getSupportedExtensions() {
|
|
308
|
-
return ['.js', '.jsx', '.mjs', '.cjs'];
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Check if auto-fix is supported
|
|
313
|
-
* @returns {boolean} True if auto-fix is supported
|
|
314
|
-
*/
|
|
315
|
-
supportsAutoFix() {
|
|
316
|
-
return true;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export default ESLintAnalyzer;
|
|
1
|
+
const a0_0x2c0877=a0_0x8d56;(function(_0x13b8fd,_0x5c0200){const _0x3dfffa=a0_0x8d56,_0xae9b3a=_0x13b8fd();while(!![]){try{const _0x1f5898=-parseInt(_0x3dfffa(0x1a1))/0x1*(-parseInt(_0x3dfffa(0x1a2))/0x2)+-parseInt(_0x3dfffa(0x1b2))/0x3+parseInt(_0x3dfffa(0x18b))/0x4+-parseInt(_0x3dfffa(0x187))/0x5+parseInt(_0x3dfffa(0x19c))/0x6+parseInt(_0x3dfffa(0x19a))/0x7+-parseInt(_0x3dfffa(0x177))/0x8;if(_0x1f5898===_0x5c0200)break;else _0xae9b3a['push'](_0xae9b3a['shift']());}catch(_0x2006e0){_0xae9b3a['push'](_0xae9b3a['shift']());}}}(a0_0x3d01,0x3a1d4));import{ESLint}from'eslint';import a0_0x8ec45d from'path';function a0_0x3d01(){const _0x1f182f=['u1rzteu','zxjYB3i','nJa5nZiZr1jtCML2','BM8TzxzHBa','rvnmAw50igfUywX5C2LZignVBxbSzxrLza','Bw9KAwzPzwq','BM8TDMfY','ywnJzxnZ','mtmZmdi1nK5PB2zHzq','lMnQCW','q0furuDpuLK','v0fstKLorW','ywX3yxLZ','uevsrK9stufoq0u','lMvZBgLUDhjJlMPZB24','y2f0zwDVCML6zvj1Bgu','rvnmAw50igzPEcbMywLSzwq','u0vdvvjjvfK','rvjst1i','BM8TAw1WBgLLzc1LDMfS','C2v2zxjPDhK','u0vwrvjjvfK','zM9YBwf0twvZC2fNzq','rM91BMqGrvnmAw50ignVBMzPzW','mtm4mJi0nuXuEuPuqq','AM9PBG','CNvSzuLK','Aw5JBhvKzxm','mtyZmduYne1JqwnUua','C2LUz2XL','zxnSAw50lMnVBMzPzY5QCW','Bwf4','BwvZC2fNzq','z2v0rvnmAw50sw5ZDgfUy2u','BgvUz3rO','C2v0DgLUz3m','ywrKzwq','zML4ywjSzuvYCM9Yq291BNq','zgv0zwn0','BgLUDfrLEhq','D2fYBG','rvnmAw50igzPEcbMywLSzwq6ia','zML4ywjSzvDHCM5PBMDdB3vUDa','mtaXntmYmNrTBLHKsa','zxH0zw5KCW','mtC2mJm5mLfZyuryrq','zxnSAw50oNjLy29TBwvUzgvK','zMLSDgvY','zw5Kq29SDw1U','BwvZC2fNzxm','odnfz1nlA08','ota2A29gzKLl','zwnTyuzLyxr1CMvZ','zML4','C3vWCg9YDhnbDxrVrML4','zxnSAw50q2fJAgu','lMPZEa','CMvHy3q','C2vJDxjPDhK','yw5HBhL6zq','qKvtvf9quKfdveLdrq','yMvZDc1WCMfJDgLJzxm','Bg9Nz2vY','zxnSAw50','zxjYB3jdB3vUDa'];a0_0x3d01=function(){return _0x1f182f;};return a0_0x3d01();}import a0_0x5a4115 from'fs/promises';import{STATIC_ANALYSIS}from'../utilities/constants.js';class ESLintAnalyzer{constructor(_0x3d70b3=null){const _0x3ae2e8=a0_0x8d56;this[_0x3ae2e8(0x1ad)]=_0x3d70b3,this[_0x3ae2e8(0x1a6)]=new Map();}async[a0_0x2c0877(0x1aa)](_0x92e208,_0x1022ac,_0x2b101a={}){const _0x202b33=a0_0x2c0877;try{const _0x2b9b9e=await this['getESLintInstance'](_0x2b101a),_0x431352=await _0x2b9b9e[_0x202b33(0x196)](_0x1022ac,{'filePath':_0x92e208,'warnIgnored':![]}),_0x3fc518=[];if(_0x431352&&_0x431352['length']>0x0){const _0x5e20e4=_0x431352[0x0];for(const _0x5dd528 of _0x5e20e4[_0x202b33(0x1a0)]){_0x3fc518['push'](this['formatMessage'](_0x5dd528,_0x92e208));}}return this['logger']?.['debug'](_0x202b33(0x1b4),{'file':_0x92e208,'totalDiagnostics':_0x3fc518['length'],'errors':_0x3fc518[_0x202b33(0x19e)](_0x4783ce=>_0x4783ce[_0x202b33(0x183)]===STATIC_ANALYSIS['SEVERITY'][_0x202b33(0x181)])['length'],'warnings':_0x3fc518[_0x202b33(0x19e)](_0xbf0564=>_0xbf0564['severity']===STATIC_ANALYSIS['SEVERITY'][_0x202b33(0x17a)])[_0x202b33(0x191)]}),_0x3fc518;}catch(_0x814040){return this['logger']?.['error']('ESLint\x20analysis\x20failed',{'file':_0x92e208,'error':_0x814040[_0x202b33(0x18f)]}),[];}}async[a0_0x2c0877(0x1a4)](_0x2a3a51,_0x2fab4a,_0x56e825={}){const _0x43728f=a0_0x2c0877;try{const _0x5dc4f2=await this['getESLintInstance']({..._0x56e825,'fix':!![]}),_0x22bb7f=await _0x5dc4f2[_0x43728f(0x196)](_0x2fab4a,{'filePath':_0x2a3a51,'warnIgnored':![]});if(_0x22bb7f&&_0x22bb7f[_0x43728f(0x191)]>0x0){const _0x3d8fa0=_0x22bb7f[0x0];return{'fixed':_0x3d8fa0['output']!==undefined,'content':_0x3d8fa0['output']||_0x2fab4a,'fixedCount':_0x3d8fa0['fixableErrorCount']+_0x3d8fa0['fixableWarningCount'],'remainingErrors':_0x3d8fa0[_0x43728f(0x1af)]-_0x3d8fa0[_0x43728f(0x194)],'remainingWarnings':_0x3d8fa0['warningCount']-_0x3d8fa0[_0x43728f(0x199)],'changes':_0x3d8fa0['output']?this['describeChanges'](_0x2fab4a,_0x3d8fa0['output']):[]};}return{'fixed':![],'content':_0x2fab4a,'fixedCount':0x0,'remainingErrors':0x0,'remainingWarnings':0x0,'changes':[]};}catch(_0x23bd22){this[_0x43728f(0x1ad)]?.[_0x43728f(0x1b1)](_0x43728f(0x17f),{'file':_0x2a3a51,'error':_0x23bd22['message']});throw new Error(_0x43728f(0x198)+_0x23bd22['message']);}}async[a0_0x2c0877(0x190)](_0x504db9={}){const {workingDir:_0x199311,fix:fix=![],framework:_0x534ccd}=_0x504db9,_0x5989b1=await this['getESLintConfig'](_0x199311,_0x534ccd),_0x343f58=new ESLint({'fix':fix,'useEslintrc':!![],'overrideConfig':_0x5989b1,'errorOnUnmatchedPattern':![]});return _0x343f58;}async['getESLintConfig'](_0x5673be,_0x132fe4){const _0x130ad0=a0_0x2c0877,_0x370ca8={'env':{'browser':!![],'es2021':!![],'node':!![]},'parserOptions':{'ecmaVersion':'latest','sourceType':'module'},'rules':{'no-unused-vars':'warn','no-undef':'error','no-console':'off','semi':[_0x130ad0(0x197),_0x130ad0(0x17b)],'quotes':['warn',_0x130ad0(0x18c),{'avoidEscape':!![]}]}};if(_0x132fe4===_0x130ad0(0x1a8))_0x370ca8['extends']=[_0x130ad0(0x19d)],_0x370ca8['parserOptions'][_0x130ad0(0x1a3)]={'jsx':!![]},_0x370ca8[_0x130ad0(0x192)]={'react':{'version':_0x130ad0(0x195)}};else _0x132fe4==='vue'?_0x370ca8[_0x130ad0(0x19b)]=['eslint:recommended']:_0x370ca8['extends']=[_0x130ad0(0x19d)];if(_0x5673be){const _0x4e1c13=['.eslintrc.js','.eslintrc.cjs',_0x130ad0(0x17d),_0x130ad0(0x18d)];for(const _0x4cf663 of _0x4e1c13){try{const _0x2d3d5=a0_0x8ec45d[_0x130ad0(0x188)](_0x5673be,_0x4cf663);return await a0_0x5a4115[_0x130ad0(0x176)](_0x2d3d5),this['logger']?.['debug'](_0x130ad0(0x186),{'configFile':_0x4cf663}),{};}catch{}}}return _0x370ca8;}[a0_0x2c0877(0x185)](_0x54dbda,_0x4528f4){const _0x169436=a0_0x2c0877;return{'file':_0x4528f4,'line':_0x54dbda['line']||0x1,'column':_0x54dbda['column']||0x1,'endLine':_0x54dbda['endLine'],'endColumn':_0x54dbda[_0x169436(0x19f)],'severity':_0x54dbda['severity']===0x2?STATIC_ANALYSIS[_0x169436(0x184)]['ERROR']:STATIC_ANALYSIS[_0x169436(0x184)]['WARNING'],'rule':_0x54dbda[_0x169436(0x189)]||'eslint','message':_0x54dbda[_0x169436(0x18f)],'category':this[_0x169436(0x17e)](_0x54dbda[_0x169436(0x189)]),'fixable':_0x54dbda['fix']!==undefined,'source':_0x169436(0x1ae)};}['categorizeRule'](_0x49ba85){const _0x251e66=a0_0x2c0877;if(!_0x49ba85)return STATIC_ANALYSIS[_0x251e66(0x179)][_0x251e66(0x1b0)];if(_0x49ba85['includes'](_0x251e66(0x1a9))||_0x49ba85['includes']('xss')||_0x49ba85===_0x251e66(0x1b3)||_0x49ba85===_0x251e66(0x182))return STATIC_ANALYSIS['CATEGORY'][_0x251e66(0x180)];if(_0x49ba85['includes']('performance')||_0x49ba85==='no-await-in-loop'||_0x49ba85==='prefer-promise-reject-errors')return STATIC_ANALYSIS[_0x251e66(0x179)][_0x251e66(0x17c)];if(_0x49ba85[_0x251e66(0x18a)]('import')||_0x49ba85==='no-undef')return STATIC_ANALYSIS['CATEGORY']['IMPORT'];if(_0x49ba85[_0x251e66(0x18a)](_0x251e66(0x1ac))||_0x49ba85==='no-unused-vars'||_0x49ba85==='no-unreachable'||_0x49ba85===_0x251e66(0x175))return STATIC_ANALYSIS['CATEGORY'][_0x251e66(0x1ab)];return STATIC_ANALYSIS[_0x251e66(0x179)][_0x251e66(0x1b0)];}['describeChanges'](_0x576617,_0x3ea0e7){const _0x44a2c9=a0_0x2c0877,_0x2657ef=[],_0x559f82=_0x576617['split']('\x0a'),_0x4bf76e=_0x3ea0e7['split']('\x0a'),_0x5bf60c=Math[_0x44a2c9(0x18e)](_0x559f82[_0x44a2c9(0x191)],_0x4bf76e[_0x44a2c9(0x191)]);for(let _0x1d061e=0x0;_0x1d061e<_0x5bf60c;_0x1d061e++){const _0x244097=_0x559f82[_0x1d061e]||'',_0x3da4f9=_0x4bf76e[_0x1d061e]||'';_0x244097!==_0x3da4f9&&_0x2657ef['push']({'line':_0x1d061e+0x1,'type':_0x244097&&_0x3da4f9?_0x44a2c9(0x174):_0x244097?'removed':_0x44a2c9(0x193),'original':_0x244097,'fixed':_0x3da4f9});}return _0x2657ef;}['getSupportedExtensions'](){const _0x41ee88=a0_0x2c0877;return['.js',_0x41ee88(0x1a7),'.mjs',_0x41ee88(0x178)];}[a0_0x2c0877(0x1a5)](){return!![];}}function a0_0x8d56(_0x15102e,_0x53a2c3){_0x15102e=_0x15102e-0x174;const _0x3d011d=a0_0x3d01();let _0x8d5600=_0x3d011d[_0x15102e];if(a0_0x8d56['RtdDfn']===undefined){var _0x4a5244=function(_0x7367f1){const _0x307821='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x8ec45d='',_0x5a4115='';for(let _0x3d70b3=0x0,_0x92e208,_0x1022ac,_0x2b101a=0x0;_0x1022ac=_0x7367f1['charAt'](_0x2b101a++);~_0x1022ac&&(_0x92e208=_0x3d70b3%0x4?_0x92e208*0x40+_0x1022ac:_0x1022ac,_0x3d70b3++%0x4)?_0x8ec45d+=String['fromCharCode'](0xff&_0x92e208>>(-0x2*_0x3d70b3&0x6)):0x0){_0x1022ac=_0x307821['indexOf'](_0x1022ac);}for(let _0x2b9b9e=0x0,_0x431352=_0x8ec45d['length'];_0x2b9b9e<_0x431352;_0x2b9b9e++){_0x5a4115+='%'+('00'+_0x8ec45d['charCodeAt'](_0x2b9b9e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5a4115);};a0_0x8d56['KvcBnK']=_0x4a5244,a0_0x8d56['RRXxBy']={},a0_0x8d56['RtdDfn']=!![];}const _0x4f19ba=_0x3d011d[0x0],_0x175d84=_0x15102e+_0x4f19ba,_0x292f14=a0_0x8d56['RRXxBy'][_0x175d84];return!_0x292f14?(_0x8d5600=a0_0x8d56['KvcBnK'](_0x8d5600),a0_0x8d56['RRXxBy'][_0x175d84]=_0x8d5600):_0x8d5600=_0x292f14,_0x8d5600;}export default ESLintAnalyzer;
|
|
@@ -1,261 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* JavaScriptAnalyzer - Analyze JavaScript files for errors using TypeScript Compiler API
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Analyze JavaScript files for syntax, type, and semantic errors
|
|
6
|
-
* - Use TypeScript Compiler API with allowJs for JavaScript analysis
|
|
7
|
-
* - Provide detailed error information with line numbers
|
|
8
|
-
* - Support JSX syntax
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import ts from 'typescript';
|
|
12
|
-
import path from 'path';
|
|
13
|
-
import { STATIC_ANALYSIS } from '../utilities/constants.js';
|
|
14
|
-
|
|
15
|
-
class JavaScriptAnalyzer {
|
|
16
|
-
constructor(logger = null) {
|
|
17
|
-
this.logger = logger;
|
|
18
|
-
this.compilerOptions = {
|
|
19
|
-
allowJs: true,
|
|
20
|
-
checkJs: true,
|
|
21
|
-
noEmit: true,
|
|
22
|
-
jsx: ts.JsxEmit.React,
|
|
23
|
-
target: ts.ScriptTarget.Latest,
|
|
24
|
-
module: ts.ModuleKind.ESNext,
|
|
25
|
-
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
|
26
|
-
esModuleInterop: true,
|
|
27
|
-
skipLibCheck: true,
|
|
28
|
-
strict: false, // Don't be too strict for JavaScript
|
|
29
|
-
noImplicitAny: false // Allow implicit any in JavaScript
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Analyze JavaScript file for errors
|
|
35
|
-
* @param {string} filePath - Path to file
|
|
36
|
-
* @param {string} content - File content
|
|
37
|
-
* @param {Object} options - Analysis options
|
|
38
|
-
* @returns {Promise<Array>} Array of diagnostic errors
|
|
39
|
-
*/
|
|
40
|
-
async analyze(filePath, content, options = {}) {
|
|
41
|
-
try {
|
|
42
|
-
const diagnostics = [];
|
|
43
|
-
|
|
44
|
-
// Create in-memory source file
|
|
45
|
-
const sourceFile = ts.createSourceFile(
|
|
46
|
-
filePath,
|
|
47
|
-
content,
|
|
48
|
-
ts.ScriptTarget.Latest,
|
|
49
|
-
true // setParentNodes
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// Get syntactic diagnostics (syntax errors)
|
|
53
|
-
const syntacticDiagnostics = this.getSyntacticDiagnostics(sourceFile);
|
|
54
|
-
diagnostics.push(...syntacticDiagnostics);
|
|
55
|
-
|
|
56
|
-
// Get semantic diagnostics (type errors, undefined variables, etc.)
|
|
57
|
-
// For JavaScript, semantic analysis is limited but still useful
|
|
58
|
-
const semanticDiagnostics = await this.getSemanticDiagnostics(filePath, content);
|
|
59
|
-
diagnostics.push(...semanticDiagnostics);
|
|
60
|
-
|
|
61
|
-
this.logger?.debug('JavaScript analysis completed', {
|
|
62
|
-
file: filePath,
|
|
63
|
-
totalDiagnostics: diagnostics.length,
|
|
64
|
-
errors: diagnostics.filter(d => d.severity === STATIC_ANALYSIS.SEVERITY.ERROR).length,
|
|
65
|
-
warnings: diagnostics.filter(d => d.severity === STATIC_ANALYSIS.SEVERITY.WARNING).length
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return diagnostics;
|
|
69
|
-
|
|
70
|
-
} catch (error) {
|
|
71
|
-
this.logger?.error('JavaScript analysis failed', {
|
|
72
|
-
file: filePath,
|
|
73
|
-
error: error.message
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return [{
|
|
77
|
-
file: filePath,
|
|
78
|
-
line: 0,
|
|
79
|
-
column: 0,
|
|
80
|
-
severity: STATIC_ANALYSIS.SEVERITY.ERROR,
|
|
81
|
-
rule: 'analyzer-error',
|
|
82
|
-
message: `Analysis failed: ${error.message}`,
|
|
83
|
-
category: STATIC_ANALYSIS.CATEGORY.SYNTAX
|
|
84
|
-
}];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get syntactic diagnostics (syntax errors)
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
getSyntacticDiagnostics(sourceFile) {
|
|
93
|
-
const diagnostics = [];
|
|
94
|
-
|
|
95
|
-
// Walk the AST to find syntax errors
|
|
96
|
-
const visit = (node) => {
|
|
97
|
-
// Check for syntax errors
|
|
98
|
-
if (node.kind === ts.SyntaxKind.Unknown) {
|
|
99
|
-
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
100
|
-
diagnostics.push({
|
|
101
|
-
file: sourceFile.fileName,
|
|
102
|
-
line: position.line + 1, // 1-indexed
|
|
103
|
-
column: position.character + 1,
|
|
104
|
-
severity: STATIC_ANALYSIS.SEVERITY.ERROR,
|
|
105
|
-
rule: 'syntax-error',
|
|
106
|
-
message: 'Syntax error',
|
|
107
|
-
category: STATIC_ANALYSIS.CATEGORY.SYNTAX,
|
|
108
|
-
fixable: false
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
ts.forEachChild(node, visit);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
visit(sourceFile);
|
|
116
|
-
|
|
117
|
-
// Also check for parsing errors
|
|
118
|
-
if (sourceFile.parseDiagnostics && sourceFile.parseDiagnostics.length > 0) {
|
|
119
|
-
for (const diagnostic of sourceFile.parseDiagnostics) {
|
|
120
|
-
diagnostics.push(this.formatDiagnostic(diagnostic, sourceFile));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return diagnostics;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Get semantic diagnostics (type errors, undefined variables)
|
|
129
|
-
* @private
|
|
130
|
-
*/
|
|
131
|
-
async getSemanticDiagnostics(filePath, content) {
|
|
132
|
-
const diagnostics = [];
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
// Create a minimal program for semantic analysis
|
|
136
|
-
const sourceFile = ts.createSourceFile(
|
|
137
|
-
filePath,
|
|
138
|
-
content,
|
|
139
|
-
ts.ScriptTarget.Latest,
|
|
140
|
-
true
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
// Create a compiler host that provides files from memory
|
|
144
|
-
const host = {
|
|
145
|
-
getSourceFile: (fileName) => {
|
|
146
|
-
if (fileName === filePath) {
|
|
147
|
-
return sourceFile;
|
|
148
|
-
}
|
|
149
|
-
return undefined;
|
|
150
|
-
},
|
|
151
|
-
getDefaultLibFileName: () => 'lib.d.ts',
|
|
152
|
-
writeFile: () => {},
|
|
153
|
-
getCurrentDirectory: () => path.dirname(filePath),
|
|
154
|
-
getDirectories: () => [],
|
|
155
|
-
fileExists: (fileName) => fileName === filePath,
|
|
156
|
-
readFile: (fileName) => {
|
|
157
|
-
if (fileName === filePath) {
|
|
158
|
-
return content;
|
|
159
|
-
}
|
|
160
|
-
return undefined;
|
|
161
|
-
},
|
|
162
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
163
|
-
useCaseSensitiveFileNames: () => true,
|
|
164
|
-
getNewLine: () => '\n'
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// Create program
|
|
168
|
-
const program = ts.createProgram({
|
|
169
|
-
rootNames: [filePath],
|
|
170
|
-
options: this.compilerOptions,
|
|
171
|
-
host
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// Get semantic diagnostics
|
|
175
|
-
const tsDiagnostics = program.getSemanticDiagnostics(sourceFile);
|
|
176
|
-
|
|
177
|
-
for (const diagnostic of tsDiagnostics) {
|
|
178
|
-
diagnostics.push(this.formatDiagnostic(diagnostic, sourceFile));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
} catch (error) {
|
|
182
|
-
this.logger?.debug('Semantic analysis skipped', {
|
|
183
|
-
file: filePath,
|
|
184
|
-
reason: error.message
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return diagnostics;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Format TypeScript diagnostic to standard error format
|
|
193
|
-
* @private
|
|
194
|
-
*/
|
|
195
|
-
formatDiagnostic(diagnostic, sourceFile) {
|
|
196
|
-
let line = 0;
|
|
197
|
-
let column = 0;
|
|
198
|
-
|
|
199
|
-
if (diagnostic.file && diagnostic.start !== undefined) {
|
|
200
|
-
const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
201
|
-
line = position.line + 1; // 1-indexed
|
|
202
|
-
column = position.character + 1;
|
|
203
|
-
} else if (sourceFile && diagnostic.start !== undefined) {
|
|
204
|
-
const position = sourceFile.getLineAndCharacterOfPosition(diagnostic.start);
|
|
205
|
-
line = position.line + 1;
|
|
206
|
-
column = position.character + 1;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
|
210
|
-
|
|
211
|
-
// Determine severity
|
|
212
|
-
let severity;
|
|
213
|
-
switch (diagnostic.category) {
|
|
214
|
-
case ts.DiagnosticCategory.Error:
|
|
215
|
-
severity = STATIC_ANALYSIS.SEVERITY.ERROR;
|
|
216
|
-
break;
|
|
217
|
-
case ts.DiagnosticCategory.Warning:
|
|
218
|
-
severity = STATIC_ANALYSIS.SEVERITY.WARNING;
|
|
219
|
-
break;
|
|
220
|
-
case ts.DiagnosticCategory.Message:
|
|
221
|
-
case ts.DiagnosticCategory.Suggestion:
|
|
222
|
-
severity = STATIC_ANALYSIS.SEVERITY.INFO;
|
|
223
|
-
break;
|
|
224
|
-
default:
|
|
225
|
-
severity = STATIC_ANALYSIS.SEVERITY.ERROR;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Determine category
|
|
229
|
-
let category = STATIC_ANALYSIS.CATEGORY.SYNTAX;
|
|
230
|
-
const code = diagnostic.code;
|
|
231
|
-
|
|
232
|
-
// Categorize based on error code
|
|
233
|
-
if (code >= 2000 && code < 3000) {
|
|
234
|
-
category = STATIC_ANALYSIS.CATEGORY.TYPE;
|
|
235
|
-
} else if (code >= 1000 && code < 2000) {
|
|
236
|
-
category = STATIC_ANALYSIS.CATEGORY.SYNTAX;
|
|
237
|
-
} else if (code >= 2300 && code < 2400) {
|
|
238
|
-
category = STATIC_ANALYSIS.CATEGORY.IMPORT;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Check if message indicates import error
|
|
242
|
-
if (message.toLowerCase().includes('cannot find module') ||
|
|
243
|
-
message.toLowerCase().includes('import')) {
|
|
244
|
-
category = STATIC_ANALYSIS.CATEGORY.IMPORT;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
file: diagnostic.file?.fileName || sourceFile?.fileName || 'unknown',
|
|
249
|
-
line,
|
|
250
|
-
column,
|
|
251
|
-
severity,
|
|
252
|
-
rule: `TS${code}`,
|
|
253
|
-
message,
|
|
254
|
-
category,
|
|
255
|
-
fixable: false, // TypeScript doesn't provide fix information easily
|
|
256
|
-
code: diagnostic.code
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export default JavaScriptAnalyzer;
|
|
1
|
+
function a0_0x5dcd(_0x1a5ce8,_0x3a12ba){_0x1a5ce8=_0x1a5ce8-0x14f;const _0x12424b=a0_0x1242();let _0x5dcd11=_0x12424b[_0x1a5ce8];if(a0_0x5dcd['pHbqsK']===undefined){var _0x44acd3=function(_0x263549){const _0x158073='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x30a0a4='',_0x525afa='';for(let _0x2d43f0=0x0,_0x4ac676,_0x35b1c8,_0x5d8118=0x0;_0x35b1c8=_0x263549['charAt'](_0x5d8118++);~_0x35b1c8&&(_0x4ac676=_0x2d43f0%0x4?_0x4ac676*0x40+_0x35b1c8:_0x35b1c8,_0x2d43f0++%0x4)?_0x30a0a4+=String['fromCharCode'](0xff&_0x4ac676>>(-0x2*_0x2d43f0&0x6)):0x0){_0x35b1c8=_0x158073['indexOf'](_0x35b1c8);}for(let _0x183b3f=0x0,_0xae841f=_0x30a0a4['length'];_0x183b3f<_0xae841f;_0x183b3f++){_0x525afa+='%'+('00'+_0x30a0a4['charCodeAt'](_0x183b3f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x525afa);};a0_0x5dcd['LDElzi']=_0x44acd3,a0_0x5dcd['UcPput']={},a0_0x5dcd['pHbqsK']=!![];}const _0xdd11b8=_0x12424b[0x0],_0x126995=_0x1a5ce8+_0xdd11b8,_0x5308fc=a0_0x5dcd['UcPput'][_0x126995];return!_0x5308fc?(_0x5dcd11=a0_0x5dcd['LDElzi'](_0x5dcd11),a0_0x5dcd['UcPput'][_0x126995]=_0x5dcd11):_0x5dcd11=_0x5308fc,_0x5dcd11;}const a0_0x5702c7=a0_0x5dcd;function a0_0x1242(){const _0x37314e=['nduWmtmXsxbrD0n4','twvZC2fNzq','sMf2yvnJCMLWDcbHBMfSExnPCYbJB21WBgv0zwq','y29TCgLSzxjpChrPB25Z','Dg9mB3DLCKnHC2u','mti4nJyZoeP1EhHVza','u3LUDgf4igvYCM9Y','yw5HBhL6zxiTzxjYB3i','u0vwrvjjvfK','z2v0u3rHCNq','u2nYAxb0vgfYz2v0','zMXHDhrLBKrPywDUB3n0AwnnzxnZywDLvgv4Da','mJa5nZa5swDsB0T6','y29Kzq','CgfYC2veAwfNBM9ZDgLJCW','ndKYnJGXufLKtLPX','nJyYmdm4nxbssM1dzG','rvjst1i','tw9KDwXLs2LUza','tgf0zxn0','ntq0otu2rwTqvw5j','v0fstKLorW','zgLYBMfTzq','su1qt1ju','Bg9Nz2vY','y3jLyxrLu291CMnLrMLSzq','ChvZAa','mZu1ntC2mNDtsNDPzG','zM9YBwf0rgLHz25VC3rPyW','rgLHz25VC3rPy0nHDgvNB3j5','nLrOA3nKBW','C2v2zxjPDhK','z2v0u2vTyw50AwneAwfNBM9ZDgLJCW','BwvZC2fNzq','tw9KDwXLuMvZB2X1DgLVBKTPBMq','zMLSDgvY','zMLSzq','u3LUDgf4s2LUza','nZi4zLz0uwjT','rvnozxH0','u1Lovefy','C3rHCNq','q0furuDpuLK','y2f0zwDVCNK','BgvUz3rO','zMLSzu5HBwu','u3vNz2vZDgLVBG','y3jLyxrLuhjVz3jHBq','BgLUzq','uMvHy3q'];a0_0x1242=function(){return _0x37314e;};return a0_0x1242();}(function(_0x3b9c8e,_0x1f7078){const _0x6e7c93=a0_0x5dcd,_0x57daf3=_0x3b9c8e();while(!![]){try{const _0x5242ee=-parseInt(_0x6e7c93(0x17c))/0x1+-parseInt(_0x6e7c93(0x14f))/0x2+parseInt(_0x6e7c93(0x165))/0x3+-parseInt(_0x6e7c93(0x15e))/0x4+-parseInt(_0x6e7c93(0x15a))/0x5+-parseInt(_0x6e7c93(0x168))/0x6*(parseInt(_0x6e7c93(0x159))/0x7)+-parseInt(_0x6e7c93(0x170))/0x8*(-parseInt(_0x6e7c93(0x156))/0x9);if(_0x5242ee===_0x1f7078)break;else _0x57daf3['push'](_0x57daf3['shift']());}catch(_0x508704){_0x57daf3['push'](_0x57daf3['shift']());}}}(a0_0x1242,0xa6618));import a0_0x30a0a4 from'typescript';import a0_0x525afa from'path';import{STATIC_ANALYSIS}from'../utilities/constants.js';class JavaScriptAnalyzer{constructor(_0x2d43f0=null){const _0x50a2f1=a0_0x5dcd;this[_0x50a2f1(0x162)]=_0x2d43f0,this['compilerOptions']={'allowJs':!![],'checkJs':!![],'noEmit':!![],'jsx':a0_0x30a0a4['JsxEmit'][_0x50a2f1(0x17b)],'target':a0_0x30a0a4[_0x50a2f1(0x154)][_0x50a2f1(0x15d)],'module':a0_0x30a0a4[_0x50a2f1(0x15c)][_0x50a2f1(0x171)],'moduleResolution':a0_0x30a0a4[_0x50a2f1(0x16c)]['NodeJs'],'esModuleInterop':!![],'skipLibCheck':!![],'strict':![],'noImplicitAny':![]};}async['analyze'](_0x4ac676,_0x35b1c8,_0x5d8118={}){const _0x49b7c7=a0_0x5dcd;try{const _0x183b3f=[],_0xae841f=a0_0x30a0a4[_0x49b7c7(0x163)](_0x4ac676,_0x35b1c8,a0_0x30a0a4[_0x49b7c7(0x154)][_0x49b7c7(0x15d)],!![]),_0x2d645b=this['getSyntacticDiagnostics'](_0xae841f);_0x183b3f['push'](..._0x2d645b);const _0x1ef8c9=await this[_0x49b7c7(0x16a)](_0x4ac676,_0x35b1c8);return _0x183b3f['push'](..._0x1ef8c9),this['logger']?.['debug'](_0x49b7c7(0x17e),{'file':_0x4ac676,'totalDiagnostics':_0x183b3f[_0x49b7c7(0x176)],'errors':_0x183b3f['filter'](_0x492b20=>_0x492b20[_0x49b7c7(0x169)]===STATIC_ANALYSIS[_0x49b7c7(0x152)]['ERROR'])['length'],'warnings':_0x183b3f[_0x49b7c7(0x16d)](_0x5b09fd=>_0x5b09fd['severity']===STATIC_ANALYSIS[_0x49b7c7(0x152)]['WARNING'])[_0x49b7c7(0x176)]}),_0x183b3f;}catch(_0x582540){return this[_0x49b7c7(0x162)]?.['error']('JavaScript\x20analysis\x20failed',{'file':_0x4ac676,'error':_0x582540['message']}),[{'file':_0x4ac676,'line':0x0,'column':0x0,'severity':STATIC_ANALYSIS[_0x49b7c7(0x152)]['ERROR'],'rule':_0x49b7c7(0x151),'message':'Analysis\x20failed:\x20'+_0x582540['message'],'category':STATIC_ANALYSIS[_0x49b7c7(0x174)][_0x49b7c7(0x172)]}];}}['getSyntacticDiagnostics'](_0x303fa8){const _0x357824=a0_0x5dcd,_0x51f754=[],_0x257ab4=_0xf0b4a0=>{const _0x1db0a8=a0_0x5dcd;if(_0xf0b4a0['kind']===a0_0x30a0a4[_0x1db0a8(0x16f)]['Unknown']){const _0x490da8=_0x303fa8['getLineAndCharacterOfPosition'](_0xf0b4a0[_0x1db0a8(0x153)]());_0x51f754[_0x1db0a8(0x164)]({'file':_0x303fa8[_0x1db0a8(0x177)],'line':_0x490da8[_0x1db0a8(0x17a)]+0x1,'column':_0x490da8['character']+0x1,'severity':STATIC_ANALYSIS[_0x1db0a8(0x152)]['ERROR'],'rule':'syntax-error','message':_0x1db0a8(0x150),'category':STATIC_ANALYSIS[_0x1db0a8(0x174)][_0x1db0a8(0x172)],'fixable':![]});}a0_0x30a0a4['forEachChild'](_0xf0b4a0,_0x257ab4);};_0x257ab4(_0x303fa8);if(_0x303fa8['parseDiagnostics']&&_0x303fa8['parseDiagnostics']['length']>0x0)for(const _0x2d3099 of _0x303fa8[_0x357824(0x158)]){_0x51f754[_0x357824(0x164)](this['formatDiagnostic'](_0x2d3099,_0x303fa8));}return _0x51f754;}async[a0_0x5702c7(0x16a)](_0x234dd9,_0x432e6e){const _0x26ea06=a0_0x5702c7,_0x313d9f=[];try{const _0x441089=a0_0x30a0a4[_0x26ea06(0x163)](_0x234dd9,_0x432e6e,a0_0x30a0a4['ScriptTarget']['Latest'],!![]),_0x5ec28a={'getSourceFile':_0x1f95f5=>{if(_0x1f95f5===_0x234dd9)return _0x441089;return undefined;},'getDefaultLibFileName':()=>'lib.d.ts','writeFile':()=>{},'getCurrentDirectory':()=>a0_0x525afa[_0x26ea06(0x160)](_0x234dd9),'getDirectories':()=>[],'fileExists':_0x2b5433=>_0x2b5433===_0x234dd9,'readFile':_0x5cefd3=>{if(_0x5cefd3===_0x234dd9)return _0x432e6e;return undefined;},'getCanonicalFileName':_0x24429f=>_0x24429f,'useCaseSensitiveFileNames':()=>!![],'getNewLine':()=>'\x0a'},_0x264156=a0_0x30a0a4[_0x26ea06(0x179)]({'rootNames':[_0x234dd9],'options':this[_0x26ea06(0x17f)],'host':_0x5ec28a}),_0x19a3b9=_0x264156[_0x26ea06(0x16a)](_0x441089);for(const _0x2c1d52 of _0x19a3b9){_0x313d9f[_0x26ea06(0x164)](this[_0x26ea06(0x166)](_0x2c1d52,_0x441089));}}catch(_0x27e268){this[_0x26ea06(0x162)]?.['debug']('Semantic\x20analysis\x20skipped',{'file':_0x234dd9,'reason':_0x27e268[_0x26ea06(0x16b)]});}return _0x313d9f;}[a0_0x5702c7(0x166)](_0x4564f7,_0x1eb098){const _0xa9726d=a0_0x5702c7;let _0x23d404=0x0,_0x561af6=0x0;if(_0x4564f7[_0xa9726d(0x16e)]&&_0x4564f7['start']!==undefined){const _0x3298e4=_0x4564f7[_0xa9726d(0x16e)]['getLineAndCharacterOfPosition'](_0x4564f7['start']);_0x23d404=_0x3298e4[_0xa9726d(0x17a)]+0x1,_0x561af6=_0x3298e4['character']+0x1;}else{if(_0x1eb098&&_0x4564f7[_0xa9726d(0x173)]!==undefined){const _0x1848f1=_0x1eb098['getLineAndCharacterOfPosition'](_0x4564f7[_0xa9726d(0x173)]);_0x23d404=_0x1848f1[_0xa9726d(0x17a)]+0x1,_0x561af6=_0x1848f1['character']+0x1;}}const _0x53c4dd=a0_0x30a0a4[_0xa9726d(0x155)](_0x4564f7['messageText'],'\x0a');let _0x13e27d;switch(_0x4564f7[_0xa9726d(0x175)]){case a0_0x30a0a4[_0xa9726d(0x167)]['Error']:_0x13e27d=STATIC_ANALYSIS[_0xa9726d(0x152)][_0xa9726d(0x15b)];break;case a0_0x30a0a4[_0xa9726d(0x167)]['Warning']:_0x13e27d=STATIC_ANALYSIS[_0xa9726d(0x152)][_0xa9726d(0x15f)];break;case a0_0x30a0a4[_0xa9726d(0x167)][_0xa9726d(0x17d)]:case a0_0x30a0a4[_0xa9726d(0x167)][_0xa9726d(0x178)]:_0x13e27d=STATIC_ANALYSIS['SEVERITY']['INFO'];break;default:_0x13e27d=STATIC_ANALYSIS[_0xa9726d(0x152)]['ERROR'];}let _0x2f71da=STATIC_ANALYSIS['CATEGORY'][_0xa9726d(0x172)];const _0x215c56=_0x4564f7[_0xa9726d(0x157)];if(_0x215c56>=0x7d0&&_0x215c56<0xbb8)_0x2f71da=STATIC_ANALYSIS['CATEGORY']['TYPE'];else{if(_0x215c56>=0x3e8&&_0x215c56<0x7d0)_0x2f71da=STATIC_ANALYSIS[_0xa9726d(0x174)][_0xa9726d(0x172)];else _0x215c56>=0x8fc&&_0x215c56<0x960&&(_0x2f71da=STATIC_ANALYSIS[_0xa9726d(0x174)][_0xa9726d(0x161)]);}return(_0x53c4dd['toLowerCase']()['includes']('cannot\x20find\x20module')||_0x53c4dd[_0xa9726d(0x180)]()['includes']('import'))&&(_0x2f71da=STATIC_ANALYSIS['CATEGORY']['IMPORT']),{'file':_0x4564f7['file']?.[_0xa9726d(0x177)]||_0x1eb098?.[_0xa9726d(0x177)]||'unknown','line':_0x23d404,'column':_0x561af6,'severity':_0x13e27d,'rule':'TS'+_0x215c56,'message':_0x53c4dd,'category':_0x2f71da,'fixable':![],'code':_0x4564f7[_0xa9726d(0x157)]};}}export default JavaScriptAnalyzer;
|