reject-eager-module-in-lazy-getter¶
拒绝为已知在启动过程中加载较早的模块定义延迟获取器,因为没有必要延迟加载它。
此规则的错误代码示例:¶
ChromeUtils.defineESModuleGetters(lazy, {
AppConstants: "resource://gre/modules/AppConstants.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
XPCOMUtils: "resource://gre/modules/XPCOMUtils.jsm",
});
此规则的正确代码示例:¶
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);