From ba37d3a3af2c5f810dabaa8d8ef37410553bc4ac Mon Sep 17 00:00:00 2001 From: c00513733 Date: Tue, 28 May 2024 15:53:25 +0800 Subject: [PATCH] Filter diagnostics for js files Issue:https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/I9SUED Signed-off-by: c00513733 Change-Id: I02462c72e3aba479bafea7cdf6647da2dcb53786 --- compiler/src/ets_checker.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 8a26ffd28..a613d93a6 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -512,7 +512,7 @@ export function mergeRollUpFiles(rollupFileList: IterableIterator, rollu } } -// collect the modulename or pkgname of all local modules. +// collect the modulename or pkgname of all local modules. export function addLocalPackageSet(moduleId: string, rollupObject: Object): void { const moduleInfo: Object = rollupObject.getModuleInfo(moduleId); const metaInfo: Object = moduleInfo.meta; @@ -599,7 +599,7 @@ function collectFileToThrowDiagnostics(file: string, fileToThrowDiagnostics: Set } fileToThrowDiagnostics.add(unixFilePath); - if (path.extname(file) === EXTNAME_JS || + if ((/\.(c|m)?js$/).test(file) || !cache[normalizedFilePath] || cache[normalizedFilePath].children.length === 0) { return; } @@ -613,12 +613,15 @@ export function collectFileToIgnoreDiagnostics(rootFileNames: string[]): void { return; } - // With arkts linter enabled, `allowJs` option is set to true, resulting JavaScript-referenced files are included - // in the program and checking process, potentially introducing new errors. For instance, in scenarios where - // an ets file imports js file imports ts file, it’s necessary to filter out errors from ts files. + // With arkts linter enabled, `allowJs` option is set to true, resulting JavaScript files themselves and + // JavaScript-referenced files are included in the tsc program and checking process, + // potentially introducing new errors. For instance, in scenarios where an ets file imports js file imports ts file, + // it’s necessary to filter out errors from ts files. let fileToThrowDiagnostics: Set = new Set(); rootFileNames.forEach(file => { - collectFileToThrowDiagnostics(file, fileToThrowDiagnostics); + if (!(/\.(c|m)?js$/).test(file)) { + collectFileToThrowDiagnostics(file, fileToThrowDiagnostics); + } }); fileToIgnoreDiagnostics = new Set(); -- Gitee