diff --git a/ets2panda/linter/src/cli/CommandLineParser.ts b/ets2panda/linter/src/cli/CommandLineParser.ts index 9849eedf17ddf941595d7bb0021890af6a008f74..9b52fbf15d7bf14aac02ac81d2e65a1180080ce0 100644 --- a/ets2panda/linter/src/cli/CommandLineParser.ts +++ b/ets2panda/linter/src/cli/CommandLineParser.ts @@ -159,7 +159,9 @@ function formArkts2Options(cmdOptions: CommandLineOptions, commanderOpts: Option function formCommandLineOptions(parsedCmd: ParsedCommand): CommandLineOptions { const opts: CommandLineOptions = { - inputFiles: parsedCmd.args.inputFiles, + inputFiles: parsedCmd.args.inputFiles.map((file) => { + return path.normalize(file); + }), linterOptions: { useRtLogic: true, interopCheckMode: false diff --git a/ets2panda/linter/src/lib/LinterRunner.ts b/ets2panda/linter/src/lib/LinterRunner.ts index 453731f7bcaf14ae41e51d199c22b75f73572acb..308bb60310c13db570f998a4fafbcd9ec301544e 100644 --- a/ets2panda/linter/src/lib/LinterRunner.ts +++ b/ets2panda/linter/src/lib/LinterRunner.ts @@ -209,16 +209,9 @@ function fix( ): boolean { const program = linterConfig.tscCompiledProgram.getProgram(); let appliedFix = false; - const mergedProblems = lintResult.problemsInfos; - if (hcResults !== undefined) { - for (const [filePath, problems] of hcResults) { - if (mergedProblems.has(filePath)) { - mergedProblems.get(filePath)!.push(...problems); - } else { - mergedProblems.set(filePath, problems); - } - } - } + // Apply homecheck fixes first to avoid them being skipped due to conflict with linter autofixes + let mergedProblems: Map = hcResults ?? new Map(); + mergedProblems = mergeArrayMaps(mergedProblems, lintResult.problemsInfos); mergedProblems.forEach((problemInfos, fileName) => { const srcFile = program.getSourceFile(fileName); if (!srcFile) { @@ -231,7 +224,8 @@ function fix( linterConfig.cmdOptions.linterOptions.arkts2 && linterConfig.cmdOptions.inputFiles.includes(fileName) && !hasUseStaticDirective(srcFile) && - linterConfig.cmdOptions.linterOptions.ideInteractive; + linterConfig.cmdOptions.linterOptions.ideInteractive && + !qEd.QuasiEditor.hasAnyAutofixes(problemInfos); // If nothing to fix or don't need to add 'use static', then skip file if (!qEd.QuasiEditor.hasAnyAutofixes(problemInfos) && !needToAddUseStatic) { return; @@ -244,7 +238,9 @@ function fix( linterConfig.cmdOptions.outputFilePath ); updatedSourceTexts.set(fileName, qe.fix(problemInfos, needToAddUseStatic)); - appliedFix = true; + if (!needToAddUseStatic) { + appliedFix = true; + } }); return appliedFix;