Outlook_Addin_LLM/node_modules/eslint-plugin-office-addins/lib/rules/no-context-sync-in-loop.js

27 lines
1.0 KiB
JavaScript

module.exports = {
name: "no-context-sync-in-loop",
meta: {
type: "problem",
messages: {
loopedSync: "Calling context.sync() inside a loop can lead to poor performance",
},
docs: {
description: "Calling context.sync() inside of a loop dramatically increases the time the code runs, proportional to the number of iterations.",
category: "Best Practices",
recommended: false,
url: "https://docs.microsoft.com/office/dev/add-ins/concepts/correlated-objects-pattern",
},
schema: [],
},
create: function (context) {
return {
":matches(ForStatement, ForInStatement, WhileStatement, DoWhileStatement, ForOfStatement) CallExpression[callee.object.name='context'][callee.property.name='sync']"(node) {
context.report({
node: node.callee,
messageId: "loopedSync",
});
},
};
},
};
//# sourceMappingURL=no-context-sync-in-loop.js.map