@lcap/nasl
Version:
NetEase Application Specific Language
32 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ruleDeleteBindAttributeNode = void 0;
// 迁移自ide-essential
const nasl_concepts_1 = require("@lcap/nasl-concepts");
const asserts_1 = require("@lcap/nasl-concepts/asserts");
const supportFixErrorReg = /找不到\s(.*)\s上的\s(.*)。/;
exports.ruleDeleteBindAttributeNode = {
isFixable(diagnostic) {
const match = diagnostic.message?.match(supportFixErrorReg);
const node = diagnostic.node;
if (match && (0, asserts_1.isBindAttribute)(node)) {
const allNodesAPI = (0, nasl_concepts_1.getConfig)()?.allNodesAPI;
const element = node?.parentNode;
if ((0, asserts_1.isViewElement)(element)) {
const api = allNodesAPI?.[element.tag];
const prop = api?.props?.find((p) => p.name === node?.name);
if ((/.*(f|F)ield$/.test(node?.name) ||
// @ts-expect-error setter 类型不存在
prop?.setter?.concept === 'PropertySelectSetter') &&
typeof node.value === 'string') {
return {};
}
}
}
return false;
},
commitFix(node) {
return node.delete();
},
};
//# sourceMappingURL=rule-delete-bind-attribute-node.js.map