mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-10-07 06:03:30 +00:00
添加systemapi和atomicservice互斥校验
Signed-off-by: fanjiaojiao0729 <fanjiaojiao@huawei.com>
This commit is contained in:
parent
2fc8a05b31
commit
eb9f0591ec
@ -636,6 +636,7 @@ const ruleArr = ['API_DOC_ATOMICSERVICE_01',
|
|||||||
'API_CHANGE_INCOMPATIBLE_34',
|
'API_CHANGE_INCOMPATIBLE_34',
|
||||||
'API_CHANGE_INCOMPATIBLE_35',
|
'API_CHANGE_INCOMPATIBLE_35',
|
||||||
'API_CHANGE_INCOMPATIBLE_36',
|
'API_CHANGE_INCOMPATIBLE_36',
|
||||||
|
'API_DOC_JSDOC_04'
|
||||||
];
|
];
|
||||||
exports.ruleArr = ruleArr;
|
exports.ruleArr = ruleArr;
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -122,7 +122,8 @@
|
|||||||
"API_DOC_JSDOC_01": "Jsdoc needs to be added to the current API.",
|
"API_DOC_JSDOC_01": "Jsdoc needs to be added to the current API.",
|
||||||
"API_DOC_JSDOC_02": "JSDoc tag validity verification failed. Please confirm if the [since] tag is missing.JSDoc tag validity verification failed. Please confirm if the [syscap] tag is missing.",
|
"API_DOC_JSDOC_02": "JSDoc tag validity verification failed. Please confirm if the [since] tag is missing.JSDoc tag validity verification failed. Please confirm if the [syscap] tag is missing.",
|
||||||
"API_DOC_JSDOC_03": "Jsdoc has chinese.",
|
"API_DOC_JSDOC_03": "Jsdoc has chinese.",
|
||||||
"API_DOC_UNKNOW_DECORATOR_01": "The [XXXX] tag does not exist. Please use a valid JSDoc tag."
|
"API_DOC_UNKNOW_DECORATOR_01": "The [XXXX] tag does not exist. Please use a valid JSDoc tag.",
|
||||||
|
"API_DOC_JSDOC_04": "The [systemapi] and [atomicservice] cannot exist in the same doc."
|
||||||
},
|
},
|
||||||
"DEFINE": {
|
"DEFINE": {
|
||||||
"API_DEFINE_UNALLOWABLE_01": "Illegal [any] keyword used in the API.",
|
"API_DEFINE_UNALLOWABLE_01": "Illegal [any] keyword used in the API.",
|
||||||
|
@ -33,6 +33,10 @@ export class LegalityCheck {
|
|||||||
*/
|
*/
|
||||||
static apiLegalityCheck(singleApi: ApiInfo, apiJsdoc: Comment.JsDocInfo): ErrorTagFormat[] {
|
static apiLegalityCheck(singleApi: ApiInfo, apiJsdoc: Comment.JsDocInfo): ErrorTagFormat[] {
|
||||||
const apiLegalityCheckResult: ErrorTagFormat[] = [];
|
const apiLegalityCheckResult: ErrorTagFormat[] = [];
|
||||||
|
|
||||||
|
//check systemapi and atomicservice
|
||||||
|
LegalityCheck.checkSystemapiAtomicservice(apiJsdoc, apiLegalityCheckResult);
|
||||||
|
|
||||||
const nodeInfo: ts.Node = singleApi.getNode() as ts.Node;
|
const nodeInfo: ts.Node = singleApi.getNode() as ts.Node;
|
||||||
const apiLegalityTagsArray: string[] = apiLegalityCheckTypeMap.get(nodeInfo.kind) as string[];
|
const apiLegalityTagsArray: string[] = apiLegalityCheckTypeMap.get(nodeInfo.kind) as string[];
|
||||||
const apiLegalityTagsSet: Set<string> = new Set(apiLegalityTagsArray);
|
const apiLegalityTagsSet: Set<string> = new Set(apiLegalityTagsArray);
|
||||||
@ -247,4 +251,25 @@ export class LegalityCheck {
|
|||||||
});
|
});
|
||||||
return illegalTagsArray;
|
return illegalTagsArray;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* systemapi and atomicservice cannot exist at the same time
|
||||||
|
* @param apiJsdoc
|
||||||
|
*/
|
||||||
|
static checkSystemapiAtomicservice(apiJsdoc: Comment.JsDocInfo, apiLegalityCheckResult: ErrorTagFormat[]) {
|
||||||
|
const apiSystemapiAtomicservice: ErrorTagFormat = {
|
||||||
|
state: true,
|
||||||
|
errorInfo: '',
|
||||||
|
};
|
||||||
|
const tagsName: string[] = [];
|
||||||
|
apiJsdoc.tags?.forEach((tag: Comment.CommentTag) => {
|
||||||
|
tagsName.push(tag.tag);
|
||||||
|
})
|
||||||
|
const hasSystemapi: boolean = tagsName.includes('systemapi');
|
||||||
|
const hasAtomicservice: boolean = tagsName.includes('atomicservice');
|
||||||
|
if (hasSystemapi && hasAtomicservice) {
|
||||||
|
apiSystemapiAtomicservice.state=false;
|
||||||
|
apiSystemapiAtomicservice.errorInfo=ErrorMessage.ERROR_ERROR_SYSTEMAPI_ATOMICSERVICE;
|
||||||
|
}
|
||||||
|
apiLegalityCheckResult.push(apiSystemapiAtomicservice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,7 @@ export enum ErrorMessage {
|
|||||||
ERROR_NO_JSDOC_TAG = 'add tags to the Jsdoc.',
|
ERROR_NO_JSDOC_TAG = 'add tags to the Jsdoc.',
|
||||||
ERROR_HAS_CHINESE = 'Jsdoc has chinese.',
|
ERROR_HAS_CHINESE = 'Jsdoc has chinese.',
|
||||||
ERROR_ERROR_CODE = 'The generic error code does not contain the current error code.',
|
ERROR_ERROR_CODE = 'The generic error code does not contain the current error code.',
|
||||||
|
ERROR_ERROR_SYSTEMAPI_ATOMICSERVICE = 'The [systemapi] and [atomicservice] cannot exist in the same doc.',
|
||||||
ERROR_CHANGES_JSDOC_LEVEL = 'Forbid changes: Cannot change from public API to system API.',
|
ERROR_CHANGES_JSDOC_LEVEL = 'Forbid changes: Cannot change from public API to system API.',
|
||||||
ERROR_CHANGES_JSDOC_PERMISSION_RANGE = 'Forbid changes: Cannot reduce or permission or increase and permission.',
|
ERROR_CHANGES_JSDOC_PERMISSION_RANGE = 'Forbid changes: Cannot reduce or permission or increase and permission.',
|
||||||
ERROR_CHANGES_JSDOC_PERMISSION_VALUE = 'Forbid changes: Cannot change permission value,cannot judge the range change.',
|
ERROR_CHANGES_JSDOC_PERMISSION_VALUE = 'Forbid changes: Cannot change permission value,cannot judge the range change.',
|
||||||
|
Loading…
Reference in New Issue
Block a user