mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-23 15:20:17 +00:00
fix:api_check门禁报错修复
Signed-off-by: fanjiaojiao <fanjiaojiao@huawei.com>
This commit is contained in:
parent
ea097eae85
commit
22fc0b2eb8
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
### permission文件配置
|
### permission文件配置
|
||||||
|
|
||||||
在api_check_plugin/config文件夹下,创建名为“config.json”的文件,用于存放permission配置文件。打开链接中的仓库,打开systemres/main/config.json文件,将文件内容复制到刚创建的api_check_plugin/config/config.json中
|
在api_check_plugin/config文件夹下,存在名为“config.json”的文件,用于存放permission配置文件。打开链接中的仓库,打开systemres/main/config.json文件,将文件内容复制到api_check_plugin/config/config.json中(覆盖原内容)
|
||||||
|
|
||||||
[utils_system_resources: Providing system resources such as fonts | 字体等系统资源 (gitee.com)](https://gitee.com/openharmony/utils_system_resources)
|
[utils_system_resources: Providing system resources such as fonts | 字体等系统资源 (gitee.com)](https://gitee.com/openharmony/utils_system_resources)
|
||||||
|
|
||||||
|
5
build-tools/api_check_plugin/config/config.json
Normal file
5
build-tools/api_check_plugin/config/config.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"module": {
|
||||||
|
"definePermissions": []
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ const urlSuffix = '/systemres/main/config.json';
|
|||||||
|
|
||||||
exports.checkJSDoc = function (node, sourceFile, fileName) {
|
exports.checkJSDoc = function (node, sourceFile, fileName) {
|
||||||
const checkLegality = require('./src/check_legality');
|
const checkLegality = require('./src/check_legality');
|
||||||
return checkLegality.checkJsDocOfCurrentNode(node, sourceFile, undefined, fileName);
|
return checkLegality.checkJsDocOfCurrentNode(node, sourceFile, fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.initEnv = function (version) {
|
exports.initEnv = function (version) {
|
||||||
|
@ -84,8 +84,7 @@ function checkAllNode(node, sourcefile, fileName) {
|
|||||||
checkPermission(node, sourcefile, fileName);
|
checkPermission(node, sourcefile, fileName);
|
||||||
|
|
||||||
if (commentNodeWhiteList.includes(node.kind)) {
|
if (commentNodeWhiteList.includes(node.kind)) {
|
||||||
const permissionConfigPath = require('../config/config.json');
|
checkJSDoc(node, sourcefile, fileName);
|
||||||
checkJSDoc(node, sourcefile, permissionConfigPath, fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,26 +54,26 @@ function checkJsDocLegality(node, comments, checkInfoMap) {
|
|||||||
// 'param'
|
// 'param'
|
||||||
legalityCheck(node, comments, [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
legalityCheck(node, comments, [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
||||||
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature, ts.SyntaxKind.Constructor], ['param'], true, checkInfoMap,
|
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature, ts.SyntaxKind.Constructor], ['param'], true, checkInfoMap,
|
||||||
(currentNode, checkResult) => {
|
(currentNode, checkResult) => {
|
||||||
if (!new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
if (!new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
||||||
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.Constructor]).has(currentNode.kind)) {
|
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.Constructor]).has(currentNode.kind)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return currentNode.parameters && currentNode.parameters.length > 0;
|
||||||
}
|
}
|
||||||
return currentNode.parameters && currentNode.parameters.length > 0;
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
// 'returns'
|
// 'returns'
|
||||||
legalityCheck(node, comments, [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
legalityCheck(node, comments, [ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
||||||
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature], ['returns'], true, checkInfoMap,
|
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature], ['returns'], true, checkInfoMap,
|
||||||
(currentNode, checkResult) => {
|
(currentNode, checkResult) => {
|
||||||
if (!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
if (!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
||||||
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature]).has(currentNode.kind)) {
|
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature]).has(currentNode.kind)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
return !(!checkResult && !new Set([ts.SyntaxKind.FunctionDeclaration, ts.SyntaxKind.MethodSignature,
|
||||||
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature]).has(currentNode.kind)) && (currentNode.type
|
ts.SyntaxKind.MethodDeclaration, ts.SyntaxKind.CallSignature]).has(currentNode.kind)) && (currentNode.type
|
||||||
&& currentNode.type.kind !== ts.SyntaxKind.VoidKeyword);
|
&& currentNode.type.kind !== ts.SyntaxKind.VoidKeyword);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 'useinstead'
|
// 'useinstead'
|
||||||
legalityCheck(node, comments, commentNodeWhiteList, ['useinstead'], true, checkInfoMap,
|
legalityCheck(node, comments, commentNodeWhiteList, ['useinstead'], true, checkInfoMap,
|
||||||
@ -244,11 +244,7 @@ function checkTagValue(tag, index, node, fileName, errorLogs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkJsDocOfCurrentNode(node, sourcefile, permissionConfigPath, fileName) {
|
function checkJsDocOfCurrentNode(node, sourcefile, fileName) {
|
||||||
let { permissionFile } = require('./utils');
|
|
||||||
if (permissionConfigPath && fs.existsSync(permissionConfigPath)) {
|
|
||||||
permissionFile = permissionConfigPath;
|
|
||||||
}
|
|
||||||
const checkInfoArray = [];
|
const checkInfoArray = [];
|
||||||
const comments = parseJsDoc(node);
|
const comments = parseJsDoc(node);
|
||||||
const checkInfoMap = checkJsDocLegality(node, comments, {});
|
const checkInfoMap = checkJsDocLegality(node, comments, {});
|
||||||
@ -281,8 +277,8 @@ function checkJsDocOfCurrentNode(node, sourcefile, permissionConfigPath, fileNam
|
|||||||
}
|
}
|
||||||
exports.checkJsDocOfCurrentNode = checkJsDocOfCurrentNode;
|
exports.checkJsDocOfCurrentNode = checkJsDocOfCurrentNode;
|
||||||
|
|
||||||
function checkJSDoc(node, sourcefile, permissionConfigPath, fileName) {
|
function checkJSDoc(node, sourcefile, fileName) {
|
||||||
const verificationResult = checkJsDocOfCurrentNode(node, sourcefile, permissionConfigPath, fileName);
|
const verificationResult = checkJsDocOfCurrentNode(node, sourcefile, fileName);
|
||||||
|
|
||||||
let isMissingTagWhitetFile = true;
|
let isMissingTagWhitetFile = true;
|
||||||
let isIllegalTagWhitetFile = true;
|
let isIllegalTagWhitetFile = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user