ignore module error

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: Id97e6c2e7a0aafbde07d0683f7ba4a54b835b2bf
This commit is contained in:
houhaoyu
2022-03-13 18:16:02 +08:00
parent 50c9232fdd
commit 7a37093198
4 changed files with 16 additions and 3 deletions
+10 -2
View File
@@ -38,7 +38,8 @@ import {
dollarCollection,
appComponentCollection,
decoratorParamsCollection,
extendCollection
extendCollection,
importModuleCollection
} from './ets_checker';
configure({
@@ -286,13 +287,20 @@ export class ResultStates {
private validateError(message: string): boolean {
const propInfoReg: RegExp = /Cannot find name\s*'(\$?\$?[_a-zA-Z0-9]+)'/;
const stateInfoReg: RegExp = /Property\s*'(\$?[_a-zA-Z0-9]+)' does not exist on type/;
const importInfoReg: RegExp = /Cannot find namespace\s*'([_a-zA-Z0-9]+)'\./;
if (this.matchMessage(message, props, propInfoReg) ||
this.matchMessage(message, props, stateInfoReg)) {
this.matchMessage(message, props, stateInfoReg) ||
this.matchMessage(message, [...importModuleCollection], importInfoReg)) {
return false;
}
return true;
}
private matchMessage(message: string, nameArr: any, reg: RegExp): boolean {
importModuleCollection.forEach(item => {
if (message.includes(item)) {
return true;
}
})
if (reg.test(message)) {
const match: string[] = message.match(reg);
if (match[1] && nameArr.includes(match[1])) {
+1
View File
@@ -134,6 +134,7 @@ export const dollarCollection: Set<string> = new Set();
export const appComponentCollection: Set<string> = new Set();
export const decoratorParamsCollection: Set<string> = new Set();
export const extendCollection: Set<string> = new Set();
export const importModuleCollection: Set<string> = new Set();
function checkUISyntax(source: string, fileName: string): void {
if (/\.ets$/.test(fileName)) {
+1 -1
View File
@@ -17,7 +17,7 @@ import path from 'path';
export const NATIVE_MODULE: Set<string> = new Set(
['system.app', 'ohos.app', 'system.router', 'system.curves', 'ohos.curves', 'system.matrix4', 'ohos.matrix4']);
export const VALIDATE_MODULE: string[] = ['application', 'util', 'screen'];
export const VALIDATE_MODULE: string[] = ['application', 'util', 'screen', 'mediaquery'];
export const SYSTEM_PLUGIN: string = 'system';
export const OHOS_PLUGIN: string = 'ohos';
+4
View File
@@ -61,6 +61,7 @@ import {
} from './utils';
import { projectConfig } from '../main';
import { collectExtend } from './process_ui_syntax';
import { importModuleCollection } from "./ets_checker";
export interface ComponentCollection {
entryComponent: string;
@@ -748,6 +749,9 @@ export function processSystemApi(content: string, isProcessWhiteList: boolean =
let moduleType: string = item2 || item5;
let systemKey: string = item3 || item6;
let systemValue: string = item1 || item4;
if (!VALIDATE_MODULE.includes(systemValue)){
importModuleCollection.add(systemValue);
}
if (!isProcessWhiteList && validateWhiteListModule(moduleType, systemKey)) {
return item;
} else if (isProcessWhiteList) {