That linter is used by Firefox addons store to verify your addon when you upload it, so it will give you warning.
You can test it locally by running web-ext lint
in your source code folder (you’ll need to have web-ext
installed).
Maybe they didn’t used it before so it was trimmed out by Webpack… (are you using Webpack?).
If you are using Webpack, you could use it to alter the created build and remove/replace these constructors.
For example, I’ve wrote a Webpack plugin that does this for some of the forbidden API:
// since many libraries use unsafe forbidden API, we use this plugin to remove it
class FirefoxLinterHotfix {
apply(compiler) {
const replacements = [
// replacing with safe alternative
{search: `Function('return this')`, replaceValue: `(() => globalThis)`},
{search: `Function("return this")`, replaceValue: `(() => globalThis)`},
// these are NOT used in Firefox build, so we replace it with empty function
{search: `iframeDocument.write`, replaceValue: `(() => ({}))`},
{search: `documentClone.write`, replaceValue: `(() => ({}))`},
];
compiler.hooks.compilation.tap('LinterHotfix', (compilation) => {
compilation.hooks.processAssets.tap({ name: 'LinterHotfix', stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL }, (assets) => {
for (const [name, source] of Object.entries(assets)) {
if (name.endsWith('.js')) {
let content = source.source();
const original = content;
for (const {search, replaceValue} of replacements) {
if (typeof content === 'string') {
content = content.replaceAll(search, replaceValue);
}
}
if (content !== original) {
console.log(chalk.bgGreen.black('\n' +
name + '\n' +
replacements.map(({search}) => original.includes(search) ? search : null).filter(Boolean).filter(unique()).join('\n')
));
compilation.updateAsset(name, new webpack.sources.RawSource(content));
}
}
}
});
});
}
}
To use it, simply add “new FirefoxLinterHotfix()” in the “plugins” array.