diff --git a/ets2panda/linter/build_linter.py b/ets2panda/linter/build_linter.py index cfc970134ce210b74707b51b6b07175bf34cb7c9..54bd9ce36ac3866be9f5cb8628edaeb403ff2205 100755 --- a/ets2panda/linter/build_linter.py +++ b/ets2panda/linter/build_linter.py @@ -265,15 +265,11 @@ def parse_args(): def main(): options = parse_args() - backup_package_files(options.source_path) - install_homecheck(options, 5, 3) install_typescript(options) node_modules_path = os.path.join(options.source_path, "node_modules") extract(options.typescript, node_modules_path, "typescript") build(options) copy_output(options) - clean_env(options.source_path) - if __name__ == '__main__': sys.exit(main()) diff --git a/ets2panda/linter/src/cli/LinterCLI.ts b/ets2panda/linter/src/cli/LinterCLI.ts index b5e981722115d5e71285605def30368aedf828c3..b97aacc9249c7146e71fdc6d97a43a0e7d2106b8 100644 --- a/ets2panda/linter/src/cli/LinterCLI.ts +++ b/ets2panda/linter/src/cli/LinterCLI.ts @@ -25,8 +25,6 @@ import { parseCommandLine } from './CommandLineParser'; import { compileLintOptions, getEtsLoaderPath } from '../lib/ts-compiler/Compiler'; import { logStatistics } from '../lib/statistics/StatisticsLogger'; import { arkts2Rules } from '../lib/utils/consts/ArkTS2Rules'; -import { MigrationTool } from 'homecheck'; -import { getHomeCheckConfigInfo, transferIssues2ProblemInfo } from '../lib/HomeCheck'; export function run(): void { const commandLineArgs = process.argv.slice(2); @@ -55,21 +53,7 @@ async function runIdeInteractiveMode(cmdOptions: CommandLineOptions): Promise(); const mergedProblems = new Map(); - - if (cmdOptions.homecheck === true) { - const { ruleConfigInfo, projectConfigInfo } = getHomeCheckConfigInfo(cmdOptions); - const migrationTool = new MigrationTool(ruleConfigInfo, projectConfigInfo); - await migrationTool.buildCheckEntry(); - const result = await migrationTool.start(); - - homeCheckResult = transferIssues2ProblemInfo(result); - for (const [filePath, problems] of homeCheckResult) { - if (!mergedProblems.has(filePath)) { - mergedProblems.set(filePath, []); - } - mergedProblems.get(filePath)!.push(...problems); - } - } + const result = lint(compileOptions, getEtsLoaderPath(compileOptions), homeCheckResult); for (const [filePath, problems] of result.problemsInfos) { diff --git a/ets2panda/linter/src/lib/HomeCheck.ts b/ets2panda/linter/src/lib/HomeCheck.ts index cbbdd29885ad42db46dea51b57d199f5cd37ed22..a60106beda2fe72d28537698cf22b3c781e1575b 100644 --- a/ets2panda/linter/src/lib/HomeCheck.ts +++ b/ets2panda/linter/src/lib/HomeCheck.ts @@ -12,87 +12,3 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import * as path from 'node:path'; -import type { FileIssues, RuleFix } from 'homecheck'; -import type { CommandLineOptions } from './CommandLineOptions'; -import type { ProblemInfo } from './ProblemInfo'; -import { FaultID } from './Problems'; - -interface RuleConfigInfo { - ruleSet: string[]; -} - -interface ProjectConfigInfo { - projectName: string | undefined; - projectPath: string | undefined; - logPath: string; - arkCheckPath: string; - ohosSdkPath: string; - hmsSdkPath: string; - reportDir: string; - languageTags: Map; - fileOrFolderToCheck: string[]; -} - -export function getHomeCheckConfigInfo(cmdOptions: CommandLineOptions): { - ruleConfigInfo: RuleConfigInfo; - projectConfigInfo: ProjectConfigInfo; -} { - const languageTags = new Map(); - const inputFiles = cmdOptions.inputFiles; - const ruleConfigInfo = { - ruleSet: ['plugin:@migration/all'], - files: ['**/*.ets', '**/*.ts', '**/*.js'] - }; - const projectConfigInfo = { - projectName: cmdOptions.arktsWholeProjectPath, - projectPath: cmdOptions.arktsWholeProjectPath, - logPath: './HomeCheck.log', - arkCheckPath: './node_modules/homecheck', - ohosSdkPath: cmdOptions.sdkDefaultApiPath ? cmdOptions.sdkDefaultApiPath : '', - hmsSdkPath: cmdOptions.sdkExternalApiPath ? cmdOptions.sdkExternalApiPath[0] : '', - reportDir: './', - languageTags: languageTags, - fileOrFolderToCheck: inputFiles - }; - return { ruleConfigInfo, projectConfigInfo }; -} - -export function transferIssues2ProblemInfo(fileIssuesArray: FileIssues[]): Map { - const result = new Map(); - fileIssuesArray.forEach((fileIssues) => { - fileIssues.issues.forEach((issueReport) => { - const defect = issueReport.defect; - const problemInfo: ProblemInfo = { - line: defect.reportLine, - column: defect.reportColumn, - endLine: defect.reportLine, - endColumn: defect.reportColumn, - start: 0, - end: 0, - type: '', - severity: defect.severity, - faultId: FaultID.LAST_ID, - problem: defect.problem, - suggest: '', - rule: defect.description, - ruleTag: -1, - autofixable: defect.fixable - }; - if (problemInfo.autofixable) { - const fix = issueReport.fix as RuleFix; - const replacementText = fix.text; - const start = fix.range[0]; - const end = fix.range[1]; - problemInfo.autofix = [{ replacementText, start, end }]; - problemInfo.autofixTitle = defect.ruleId; - } - const filePath = path.normalize(defect.mergeKey.split('%')[0]); - const problems = result.get(filePath) || []; - problems.push(problemInfo); - result.set(filePath, problems); - }); - }); - return result; -}