@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.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.
- 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 +14 -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
|
+
function a0_0x59db(){const _0x1f8d38=['Bw9KAwzPzwq','lMPZ','mZyZotG0ofHKs0fTvW','B2zM','y2f0zwDVCML6zvj1Bgu','BgvUz3rO','zM9YBwf0twvZC2fNzq','rvnmAw50igfUywX5C2LZigzHAwXLza','u0vwrvjjvfK','BwvZC2fNzq','mtaXmtG3mtbuu2fxzMW','mw9wz29YEq','C2LUz2XL','u1rzteu','zML4ywjSzuvYCM9Yq291BNq','lMvZBgLUDhjJlMnQCW','zxnSAw50','BgLUzq','zw5KtgLUzq','rvnmAw50igzPEcbMywLSzwq6ia','y29SDw1U','v0fstKLorW','D2fYBG','C2v2zxjPDhK','Aw5JBhvKzxm','DNvL','mJG2mdjXwgzpse4','nZzPqxrqzKK','EhnZ','BM8TAw1WBgLLzc1LDMfS','mtuYndnvu3DwCKK','zML4ywjSzvDHCM5PBMDdB3vUDa','zxjYB3i','C3bSAxq','Bw9KDwXL','BgLUDfrLEhq','uevsrK9stufoq0u','mtGXndKZmxHqBLvuyq','z2v0rvnmAw50sw5ZDgfUy2u','Bgf0zxn0','ChjLzMvYlxbYB21PC2uTCMvQzwn0lwvYCM9YCW','z2v0rvnmAw50q29UzMLN','q0furuDpuLK','zgvZy3jPyMvdAgfUz2vZ','mtG5tujMvw9t','mJqXnta0mg14vvnJCW','CNvSzuLK','rvjst1i','Bg9Nz2vY','nZy2ndy2yvfKv3zM','ywnJzxnZ','CgvYzM9YBwfUy2u','D2fYBMLUz0nVDw50','zgvIDwC','AM9PBG','su1qt1ju','ChvZAa','BwvZC2fNzxm'];a0_0x59db=function(){return _0x1f8d38;};return a0_0x59db();}const a0_0x3d73b8=a0_0x4edd;(function(_0x3cd62b,_0x39a271){const _0x5c9d04=a0_0x4edd,_0x1d1767=_0x3cd62b();while(!![]){try{const _0x198261=parseInt(_0x5c9d04(0x1c7))/0x1*(parseInt(_0x5c9d04(0x1b3))/0x2)+-parseInt(_0x5c9d04(0x1a0))/0x3*(parseInt(_0x5c9d04(0x19d))/0x4)+-parseInt(_0x5c9d04(0x1af))/0x5+parseInt(_0x5c9d04(0x19c))/0x6*(parseInt(_0x5c9d04(0x1ae))/0x7)+-parseInt(_0x5c9d04(0x1be))/0x8+-parseInt(_0x5c9d04(0x1a7))/0x9+parseInt(_0x5c9d04(0x1c6))/0xa;if(_0x198261===_0x39a271)break;else _0x1d1767['push'](_0x1d1767['shift']());}catch(_0xc3cd36){_0x1d1767['push'](_0x1d1767['shift']());}}}(a0_0x59db,0x4638a));import{ESLint}from'eslint';import a0_0x11cbaf from'path';function a0_0x4edd(_0x519aad,_0x24fb0a){_0x519aad=_0x519aad-0x19b;const _0x59dbe9=a0_0x59db();let _0x4eddda=_0x59dbe9[_0x519aad];if(a0_0x4edd['jBwMIm']===undefined){var _0x461126=function(_0x512250){const _0x4bf6a1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x11cbaf='',_0xa75e8='';for(let _0x293df6=0x0,_0x2883b9,_0x5a205d,_0x52e105=0x0;_0x5a205d=_0x512250['charAt'](_0x52e105++);~_0x5a205d&&(_0x2883b9=_0x293df6%0x4?_0x2883b9*0x40+_0x5a205d:_0x5a205d,_0x293df6++%0x4)?_0x11cbaf+=String['fromCharCode'](0xff&_0x2883b9>>(-0x2*_0x293df6&0x6)):0x0){_0x5a205d=_0x4bf6a1['indexOf'](_0x5a205d);}for(let _0x29af81=0x0,_0x2c5573=_0x11cbaf['length'];_0x29af81<_0x2c5573;_0x29af81++){_0xa75e8+='%'+('00'+_0x11cbaf['charCodeAt'](_0x29af81)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xa75e8);};a0_0x4edd['UnqNYi']=_0x461126,a0_0x4edd['HrbnfB']={},a0_0x4edd['jBwMIm']=!![];}const _0x1e441b=_0x59dbe9[0x0],_0x43eaf4=_0x519aad+_0x1e441b,_0x102b2f=a0_0x4edd['HrbnfB'][_0x43eaf4];return!_0x102b2f?(_0x4eddda=a0_0x4edd['UnqNYi'](_0x4eddda),a0_0x4edd['HrbnfB'][_0x43eaf4]=_0x4eddda):_0x4eddda=_0x102b2f,_0x4eddda;}import a0_0xa75e8 from'fs/promises';import{STATIC_ANALYSIS}from'../utilities/constants.js';class ESLintAnalyzer{constructor(_0x293df6=null){const _0x348ff5=a0_0x4edd;this[_0x348ff5(0x1b2)]=_0x293df6,this['eslintCache']=new Map();}async['analyze'](_0x2883b9,_0x5a205d,_0x52e105={}){const _0x52aabc=a0_0x4edd;try{const _0x29af81=await this['getESLintInstance'](_0x52e105),_0x2c5573=await _0x29af81[_0x52aabc(0x1a5)](_0x5a205d,{'filePath':_0x2883b9,'warnIgnored':![]}),_0x2b5dec=[];if(_0x2c5573&&_0x2c5573['length']>0x0){const _0x31b0c9=_0x2c5573[0x0];for(const _0x540d38 of _0x31b0c9[_0x52aabc(0x1bb)]){_0x2b5dec['push'](this[_0x52aabc(0x1c2)](_0x540d38,_0x2883b9));}}return this[_0x52aabc(0x1b2)]?.[_0x52aabc(0x1b7)]('ESLint\x20analysis\x20completed',{'file':_0x2883b9,'totalDiagnostics':_0x2b5dec['length'],'errors':_0x2b5dec['filter'](_0x30eb4f=>_0x30eb4f[_0x52aabc(0x1d3)]===STATIC_ANALYSIS[_0x52aabc(0x1c4)][_0x52aabc(0x1b1)])[_0x52aabc(0x1c1)],'warnings':_0x2b5dec['filter'](_0x158139=>_0x158139[_0x52aabc(0x1d3)]===STATIC_ANALYSIS[_0x52aabc(0x1c4)]['WARNING'])[_0x52aabc(0x1c1)]}),_0x2b5dec;}catch(_0x2a7838){return this['logger']?.[_0x52aabc(0x1a2)](_0x52aabc(0x1c3),{'file':_0x2883b9,'error':_0x2a7838[_0x52aabc(0x1c5)]}),[];}}async['fix'](_0x504b57,_0x2a5a8c,_0x3a0e10={}){const _0x17fe40=a0_0x4edd;try{const _0x4e8124=await this[_0x17fe40(0x1a8)]({..._0x3a0e10,'fix':!![]}),_0x757de6=await _0x4e8124[_0x17fe40(0x1a5)](_0x2a5a8c,{'filePath':_0x504b57,'warnIgnored':![]});if(_0x757de6&&_0x757de6[_0x17fe40(0x1c1)]>0x0){const _0x5773dc=_0x757de6[0x0];return{'fixed':_0x5773dc['output']!==undefined,'content':_0x5773dc['output']||_0x2a5a8c,'fixedCount':_0x5773dc[_0x17fe40(0x1ca)]+_0x5773dc[_0x17fe40(0x1a1)],'remainingErrors':_0x5773dc['errorCount']-_0x5773dc[_0x17fe40(0x1ca)],'remainingWarnings':_0x5773dc[_0x17fe40(0x1b6)]-_0x5773dc['fixableWarningCount'],'changes':_0x5773dc['output']?this[_0x17fe40(0x1ad)](_0x2a5a8c,_0x5773dc['output']):[]};}return{'fixed':![],'content':_0x2a5a8c,'fixedCount':0x0,'remainingErrors':0x0,'remainingWarnings':0x0,'changes':[]};}catch(_0x1966d2){this['logger']?.[_0x17fe40(0x1a2)]('ESLint\x20fix\x20failed',{'file':_0x504b57,'error':_0x1966d2['message']});throw new Error(_0x17fe40(0x1cf)+_0x1966d2[_0x17fe40(0x1c5)]);}}async[a0_0x3d73b8(0x1a8)](_0x2fb71a={}){const _0x29b291=a0_0x3d73b8,{workingDir:_0x21dd00,fix:fix=![],framework:_0x3c8474}=_0x2fb71a,_0x40f5eb=await this[_0x29b291(0x1ab)](_0x21dd00,_0x3c8474),_0x52302d=new ESLint({'fix':fix,'useEslintrc':!![],'overrideConfig':_0x40f5eb,'errorOnUnmatchedPattern':![]});return _0x52302d;}async[a0_0x3d73b8(0x1ab)](_0x2f02b7,_0x382ebd){const _0x49264f=a0_0x3d73b8,_0x336266={'env':{'browser':!![],'es2021':!![],'node':!![]},'parserOptions':{'ecmaVersion':_0x49264f(0x1a9),'sourceType':_0x49264f(0x1a4)},'rules':{'no-unused-vars':_0x49264f(0x1d2),'no-undef':'error','no-console':_0x49264f(0x1bf),'semi':['warn','always'],'quotes':[_0x49264f(0x1d2),_0x49264f(0x1c8),{'avoidEscape':!![]}]}};if(_0x382ebd==='react')_0x336266['extends']=['eslint:recommended'],_0x336266['parserOptions']['ecmaFeatures']={'jsx':!![]},_0x336266['settings']={'react':{'version':'detect'}};else _0x382ebd===_0x49264f(0x19b)?_0x336266['extends']=['eslint:recommended']:_0x336266['extends']=['eslint:recommended'];if(_0x2f02b7){const _0x9dc53a=['.eslintrc.js',_0x49264f(0x1cb),'.eslintrc.json','eslint.config.js'];for(const _0x5b3061 of _0x9dc53a){try{const _0xc4a375=a0_0x11cbaf[_0x49264f(0x1b8)](_0x2f02b7,_0x5b3061);return await a0_0xa75e8[_0x49264f(0x1b4)](_0xc4a375),this['logger']?.[_0x49264f(0x1b7)]('Found\x20ESLint\x20config',{'configFile':_0x5b3061}),{};}catch{}}}return _0x336266;}['formatMessage'](_0x32acf0,_0x451480){const _0x1905ee=a0_0x3d73b8;return{'file':_0x451480,'line':_0x32acf0[_0x1905ee(0x1cd)]||0x1,'column':_0x32acf0[_0x1905ee(0x1d0)]||0x1,'endLine':_0x32acf0[_0x1905ee(0x1ce)],'endColumn':_0x32acf0['endColumn'],'severity':_0x32acf0['severity']===0x2?STATIC_ANALYSIS[_0x1905ee(0x1c4)][_0x1905ee(0x1b1)]:STATIC_ANALYSIS[_0x1905ee(0x1c4)][_0x1905ee(0x1d1)],'rule':_0x32acf0[_0x1905ee(0x1b0)]||'eslint','message':_0x32acf0[_0x1905ee(0x1c5)],'category':this['categorizeRule'](_0x32acf0['ruleId']),'fixable':_0x32acf0['fix']!==undefined,'source':_0x1905ee(0x1cc)};}[a0_0x3d73b8(0x1c0)](_0x56ed0c){const _0x21fbe5=a0_0x3d73b8;if(!_0x56ed0c)return STATIC_ANALYSIS[_0x21fbe5(0x1ac)][_0x21fbe5(0x1c9)];if(_0x56ed0c['includes']('security')||_0x56ed0c[_0x21fbe5(0x1d4)](_0x21fbe5(0x19e))||_0x56ed0c==='no-eval'||_0x56ed0c===_0x21fbe5(0x19f))return STATIC_ANALYSIS[_0x21fbe5(0x1ac)]['SECURITY'];if(_0x56ed0c[_0x21fbe5(0x1d4)](_0x21fbe5(0x1b5))||_0x56ed0c==='no-await-in-loop'||_0x56ed0c===_0x21fbe5(0x1aa))return STATIC_ANALYSIS['CATEGORY'][_0x21fbe5(0x1a6)];if(_0x56ed0c['includes']('import')||_0x56ed0c==='no-undef')return STATIC_ANALYSIS[_0x21fbe5(0x1ac)][_0x21fbe5(0x1b9)];if(_0x56ed0c['includes']('best-practices')||_0x56ed0c==='no-unused-vars'||_0x56ed0c==='no-unreachable'||_0x56ed0c==='no-var')return STATIC_ANALYSIS[_0x21fbe5(0x1ac)]['BEST_PRACTICE'];return STATIC_ANALYSIS[_0x21fbe5(0x1ac)]['STYLE'];}[a0_0x3d73b8(0x1ad)](_0xf16068,_0x5e957e){const _0x15ff5b=a0_0x3d73b8,_0x1c597e=[],_0x496840=_0xf16068['split']('\x0a'),_0x2c6f15=_0x5e957e[_0x15ff5b(0x1a3)]('\x0a'),_0x559a34=Math['max'](_0x496840[_0x15ff5b(0x1c1)],_0x2c6f15['length']);for(let _0x46e57c=0x0;_0x46e57c<_0x559a34;_0x46e57c++){const _0x68bbc5=_0x496840[_0x46e57c]||'',_0x4c2394=_0x2c6f15[_0x46e57c]||'';_0x68bbc5!==_0x4c2394&&_0x1c597e[_0x15ff5b(0x1ba)]({'line':_0x46e57c+0x1,'type':_0x68bbc5&&_0x4c2394?_0x15ff5b(0x1bc):_0x68bbc5?'removed':'added','original':_0x68bbc5,'fixed':_0x4c2394});}return _0x1c597e;}['getSupportedExtensions'](){const _0x1d7cd7=a0_0x3d73b8;return[_0x1d7cd7(0x1bd),'.jsx','.mjs','.cjs'];}['supportsAutoFix'](){return!![];}}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
|
+
const a0_0x1934a5=a0_0x2db7;(function(_0x346448,_0x33f816){const _0x111daf=a0_0x2db7,_0x139f34=_0x346448();while(!![]){try{const _0xde871c=-parseInt(_0x111daf(0x178))/0x1*(parseInt(_0x111daf(0x16c))/0x2)+parseInt(_0x111daf(0x17c))/0x3*(parseInt(_0x111daf(0x16d))/0x4)+-parseInt(_0x111daf(0x173))/0x5+parseInt(_0x111daf(0x17f))/0x6+parseInt(_0x111daf(0x17d))/0x7*(parseInt(_0x111daf(0x179))/0x8)+-parseInt(_0x111daf(0x184))/0x9+-parseInt(_0x111daf(0x170))/0xa*(-parseInt(_0x111daf(0x17a))/0xb);if(_0xde871c===_0x33f816)break;else _0x139f34['push'](_0x139f34['shift']());}catch(_0x34fa22){_0x139f34['push'](_0x139f34['shift']());}}}(a0_0x4595,0x4a093));import a0_0x433370 from'typescript';import a0_0x5859dc from'path';import{STATIC_ANALYSIS}from'../utilities/constants.js';function a0_0x2db7(_0x27457a,_0x3ab79e){_0x27457a=_0x27457a-0x151;const _0x459547=a0_0x4595();let _0x2db78f=_0x459547[_0x27457a];if(a0_0x2db7['XayiEX']===undefined){var _0x302784=function(_0x128da8){const _0x4a7421='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x433370='',_0x5859dc='';for(let _0x588914=0x0,_0x52e71d,_0x5744c6,_0x404f9e=0x0;_0x5744c6=_0x128da8['charAt'](_0x404f9e++);~_0x5744c6&&(_0x52e71d=_0x588914%0x4?_0x52e71d*0x40+_0x5744c6:_0x5744c6,_0x588914++%0x4)?_0x433370+=String['fromCharCode'](0xff&_0x52e71d>>(-0x2*_0x588914&0x6)):0x0){_0x5744c6=_0x4a7421['indexOf'](_0x5744c6);}for(let _0x5c2d83=0x0,_0x5eca12=_0x433370['length'];_0x5c2d83<_0x5eca12;_0x5c2d83++){_0x5859dc+='%'+('00'+_0x433370['charCodeAt'](_0x5c2d83)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5859dc);};a0_0x2db7['IYFbme']=_0x302784,a0_0x2db7['tnEyAa']={},a0_0x2db7['XayiEX']=!![];}const _0x436475=_0x459547[0x0],_0x53791e=_0x27457a+_0x436475,_0x12f950=a0_0x2db7['tnEyAa'][_0x53791e];return!_0x12f950?(_0x2db78f=a0_0x2db7['IYFbme'](_0x2db78f),a0_0x2db7['tnEyAa'][_0x53791e]=_0x2db78f):_0x2db78f=_0x12f950,_0x2db78f;}function a0_0x4595(){const _0x309d74=['BgLUzq','y3jLyxrLu291CMnLrMLSzq','Dg9mB3DLCKnHC2u','CgfYC2veAwfNBM9ZDgLJCW','q0furuDpuLK','ChvZAa','z2v0u2vTyw50AwneAwfNBM9ZDgLJCW','tw9KDwXLuMvZB2X1DgLVBKTPBMq','sNn4rw1PDa','u2nYAxb0vgfYz2v0','Bg9Nz2vY','ndm3ndHVDhPxuuG','nfj3thLTBW','u1Lovefy','BgvUz3rO','mZblAeHSvKy','z2v0tgLUzufUzenOyxjHy3rLCK9Mug9ZAxrPB24','tgf0zxn0','mtqYmteWt2XkuLDM','zgLYBMfTzq','u3LUDgf4igvYCM9Y','C3rHCNq','rvjst1i','nKrLvuf4DG','nJGXmtyWweDTs3n0','mti0oda5m1HnCu5nBq','sMf2yvnJCMLWDcbHBMfSExnPCYbJB21WBgv0zwq','mZC2mde3ELLszu5O','mtrqBK9QD1u','yw5HBhL6zq','mtG1ndm5nMHJCKD2vW','zMLSzq','rxjYB3i','v2fYBMLUzW','zMLSzu5HBwu','ndmZotuWm01dwufPrW','rvnozxH0','y29Kzq','vfLqrq','y2HHCMfJDgvY','z2v0u3LUDgfJDgLJrgLHz25VC3rPy3m','zM9YBwf0rgLHz25VC3rPyW','u0vwrvjjvfK','su1qt1ju','rgLHz25VC3rPy0nHDgvNB3j5','v0fstKLorW','y29TCgLSzxjpChrPB25Z','Dw5RBM93BG','zgvIDwC','BwvZC2fNzq','C2v2zxjPDhK','tw9KDwXLs2LUza'];a0_0x4595=function(){return _0x309d74;};return a0_0x4595();}class JavaScriptAnalyzer{constructor(_0x588914=null){const _0x59de9d=a0_0x2db7;this[_0x59de9d(0x16b)]=_0x588914,this['compilerOptions']={'allowJs':!![],'checkJs':!![],'noEmit':!![],'jsx':a0_0x433370[_0x59de9d(0x169)]['React'],'target':a0_0x433370[_0x59de9d(0x16a)]['Latest'],'module':a0_0x433370[_0x59de9d(0x160)][_0x59de9d(0x151)],'moduleResolution':a0_0x433370[_0x59de9d(0x168)]['NodeJs'],'esModuleInterop':!![],'skipLibCheck':!![],'strict':![],'noImplicitAny':![]};}async[a0_0x1934a5(0x17e)](_0x52e71d,_0x5744c6,_0x404f9e={}){const _0x250b3e=a0_0x1934a5;try{const _0x5c2d83=[],_0x5eca12=a0_0x433370[_0x250b3e(0x162)](_0x52e71d,_0x5744c6,a0_0x433370['ScriptTarget'][_0x250b3e(0x172)],!![]),_0x1bc02d=this['getSyntacticDiagnostics'](_0x5eca12);_0x5c2d83['push'](..._0x1bc02d);const _0x563893=await this[_0x250b3e(0x167)](_0x52e71d,_0x5744c6);return _0x5c2d83['push'](..._0x563893),this[_0x250b3e(0x16b)]?.[_0x250b3e(0x15d)](_0x250b3e(0x17b),{'file':_0x52e71d,'totalDiagnostics':_0x5c2d83['length'],'errors':_0x5c2d83['filter'](_0x36d054=>_0x36d054[_0x250b3e(0x15f)]===STATIC_ANALYSIS[_0x250b3e(0x157)][_0x250b3e(0x177)])[_0x250b3e(0x16f)],'warnings':_0x5c2d83['filter'](_0xb45c3d=>_0xb45c3d['severity']===STATIC_ANALYSIS[_0x250b3e(0x157)]['WARNING'])['length']}),_0x5c2d83;}catch(_0x123a57){return this['logger']?.['error']('JavaScript\x20analysis\x20failed',{'file':_0x52e71d,'error':_0x123a57[_0x250b3e(0x15e)]}),[{'file':_0x52e71d,'line':0x0,'column':0x0,'severity':STATIC_ANALYSIS['SEVERITY']['ERROR'],'rule':'analyzer-error','message':'Analysis\x20failed:\x20'+_0x123a57['message'],'category':STATIC_ANALYSIS['CATEGORY'][_0x250b3e(0x16e)]}];}}[a0_0x1934a5(0x155)](_0x3d0d3c){const _0x1d2ae8=a0_0x1934a5,_0x207570=[],_0x15a6ae=_0x41043e=>{const _0x2a79cd=a0_0x2db7;if(_0x41043e['kind']===a0_0x433370['SyntaxKind']['Unknown']){const _0x51f46c=_0x3d0d3c[_0x2a79cd(0x171)](_0x41043e['getStart']());_0x207570['push']({'file':_0x3d0d3c['fileName'],'line':_0x51f46c['line']+0x1,'column':_0x51f46c[_0x2a79cd(0x154)]+0x1,'severity':STATIC_ANALYSIS['SEVERITY']['ERROR'],'rule':'syntax-error','message':_0x2a79cd(0x175),'category':STATIC_ANALYSIS[_0x2a79cd(0x165)]['SYNTAX'],'fixable':![]});}a0_0x433370['forEachChild'](_0x41043e,_0x15a6ae);};_0x15a6ae(_0x3d0d3c);if(_0x3d0d3c['parseDiagnostics']&&_0x3d0d3c['parseDiagnostics'][_0x1d2ae8(0x16f)]>0x0)for(const _0x2e3e12 of _0x3d0d3c[_0x1d2ae8(0x164)]){_0x207570[_0x1d2ae8(0x166)](this[_0x1d2ae8(0x156)](_0x2e3e12,_0x3d0d3c));}return _0x207570;}async[a0_0x1934a5(0x167)](_0x4a2fc7,_0x5d9af8){const _0x4f1e96=a0_0x1934a5,_0x275610=[];try{const _0x21c057=a0_0x433370[_0x4f1e96(0x162)](_0x4a2fc7,_0x5d9af8,a0_0x433370[_0x4f1e96(0x16a)]['Latest'],!![]),_0x31ea09={'getSourceFile':_0x28ebb7=>{if(_0x28ebb7===_0x4a2fc7)return _0x21c057;return undefined;},'getDefaultLibFileName':()=>'lib.d.ts','writeFile':()=>{},'getCurrentDirectory':()=>a0_0x5859dc[_0x4f1e96(0x174)](_0x4a2fc7),'getDirectories':()=>[],'fileExists':_0x4dc10d=>_0x4dc10d===_0x4a2fc7,'readFile':_0x524a60=>{if(_0x524a60===_0x4a2fc7)return _0x5d9af8;return undefined;},'getCanonicalFileName':_0x499638=>_0x499638,'useCaseSensitiveFileNames':()=>!![],'getNewLine':()=>'\x0a'},_0x11ecd8=a0_0x433370['createProgram']({'rootNames':[_0x4a2fc7],'options':this[_0x4f1e96(0x15b)],'host':_0x31ea09}),_0x4baa45=_0x11ecd8[_0x4f1e96(0x167)](_0x21c057);for(const _0x453280 of _0x4baa45){_0x275610[_0x4f1e96(0x166)](this[_0x4f1e96(0x156)](_0x453280,_0x21c057));}}catch(_0x54cc04){this['logger']?.[_0x4f1e96(0x15d)]('Semantic\x20analysis\x20skipped',{'file':_0x4a2fc7,'reason':_0x54cc04[_0x4f1e96(0x15e)]});}return _0x275610;}[a0_0x1934a5(0x156)](_0x3444e5,_0x51d754){const _0x303c6c=a0_0x1934a5;let _0x219f03=0x0,_0x34c3dd=0x0;if(_0x3444e5[_0x303c6c(0x180)]&&_0x3444e5['start']!==undefined){const _0x20dc79=_0x3444e5['file'][_0x303c6c(0x171)](_0x3444e5[_0x303c6c(0x176)]);_0x219f03=_0x20dc79[_0x303c6c(0x161)]+0x1,_0x34c3dd=_0x20dc79['character']+0x1;}else{if(_0x51d754&&_0x3444e5['start']!==undefined){const _0x597b1f=_0x51d754[_0x303c6c(0x171)](_0x3444e5[_0x303c6c(0x176)]);_0x219f03=_0x597b1f[_0x303c6c(0x161)]+0x1,_0x34c3dd=_0x597b1f['character']+0x1;}}const _0x5d732f=a0_0x433370['flattenDiagnosticMessageText'](_0x3444e5['messageText'],'\x0a');let _0x1c3f83;switch(_0x3444e5['category']){case a0_0x433370['DiagnosticCategory'][_0x303c6c(0x181)]:_0x1c3f83=STATIC_ANALYSIS[_0x303c6c(0x157)]['ERROR'];break;case a0_0x433370[_0x303c6c(0x159)][_0x303c6c(0x182)]:_0x1c3f83=STATIC_ANALYSIS[_0x303c6c(0x157)][_0x303c6c(0x15a)];break;case a0_0x433370[_0x303c6c(0x159)]['Message']:case a0_0x433370[_0x303c6c(0x159)]['Suggestion']:_0x1c3f83=STATIC_ANALYSIS[_0x303c6c(0x157)]['INFO'];break;default:_0x1c3f83=STATIC_ANALYSIS[_0x303c6c(0x157)]['ERROR'];}let _0x18b78c=STATIC_ANALYSIS[_0x303c6c(0x165)][_0x303c6c(0x16e)];const _0x6c972=_0x3444e5['code'];if(_0x6c972>=0x7d0&&_0x6c972<0xbb8)_0x18b78c=STATIC_ANALYSIS[_0x303c6c(0x165)][_0x303c6c(0x153)];else{if(_0x6c972>=0x3e8&&_0x6c972<0x7d0)_0x18b78c=STATIC_ANALYSIS['CATEGORY']['SYNTAX'];else _0x6c972>=0x8fc&&_0x6c972<0x960&&(_0x18b78c=STATIC_ANALYSIS['CATEGORY']['IMPORT']);}return(_0x5d732f['toLowerCase']()['includes']('cannot\x20find\x20module')||_0x5d732f[_0x303c6c(0x163)]()['includes']('import'))&&(_0x18b78c=STATIC_ANALYSIS['CATEGORY'][_0x303c6c(0x158)]),{'file':_0x3444e5[_0x303c6c(0x180)]?.['fileName']||_0x51d754?.[_0x303c6c(0x183)]||_0x303c6c(0x15c),'line':_0x219f03,'column':_0x34c3dd,'severity':_0x1c3f83,'rule':'TS'+_0x6c972,'message':_0x5d732f,'category':_0x18b78c,'fixable':![],'code':_0x3444e5[_0x303c6c(0x152)]};}}export default JavaScriptAnalyzer;
|