Files
powerpoint-toolbox/node_modules/eslint-plugin-office-addins/lib/rules/no-context-sync-in-loop.js
T
2025-03-07 19:22:02 +01:00

28 lines
1.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
exports.default = utils_1.ESLintUtils.RuleCreator(() => "https://docs.microsoft.com/office/dev/add-ins/concepts/correlated-objects-pattern")({
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.",
},
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",
});
},
};
},
defaultOptions: [],
});
//# sourceMappingURL=no-context-sync-in-loop.js.map