Loading docs/code-quality/lint/linters/eslint-plugin-mozilla/import-globals-from.rst +4 −0 Original line number Diff line number Diff line Loading @@ -12,3 +12,7 @@ on each other's globals. If <path> is a relative path, then it must be relative to the file being checked by the rule. Note: ``import-globals-from`` does not support loading globals from ES modules. These should be imported as variable definitions directly, or the file where they are imported should be referenced. tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js +18 −1 Original line number Diff line number Diff line Loading @@ -81,8 +81,9 @@ var lastHTMLGlobals = {}; * @param {String} filePath * The absolute path of the file being parsed. */ function GlobalsForNode(filePath) { function GlobalsForNode(filePath, context) { this.path = filePath; this.context = context; if (this.path) { this.dirname = path.dirname(this.path); Loading Loading @@ -128,6 +129,22 @@ GlobalsForNode.prototype = { let filePath = match[1].trim(); if (filePath.endsWith(".mjs")) { if (this.context) { this.context.report( comment, "import-globals-from does not support module files - use a direct import instead" ); } else { // Fall back to throwing an error, as we do not have a context in all situations, // e.g. when loading the environment. throw new Error( "import-globals-from does not support module files - use a direct import instead" ); } continue; } if (!path.isAbsolute(filePath)) { filePath = path.resolve(this.dirname, filePath); } else { Loading Loading
docs/code-quality/lint/linters/eslint-plugin-mozilla/import-globals-from.rst +4 −0 Original line number Diff line number Diff line Loading @@ -12,3 +12,7 @@ on each other's globals. If <path> is a relative path, then it must be relative to the file being checked by the rule. Note: ``import-globals-from`` does not support loading globals from ES modules. These should be imported as variable definitions directly, or the file where they are imported should be referenced.
tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js +18 −1 Original line number Diff line number Diff line Loading @@ -81,8 +81,9 @@ var lastHTMLGlobals = {}; * @param {String} filePath * The absolute path of the file being parsed. */ function GlobalsForNode(filePath) { function GlobalsForNode(filePath, context) { this.path = filePath; this.context = context; if (this.path) { this.dirname = path.dirname(this.path); Loading Loading @@ -128,6 +129,22 @@ GlobalsForNode.prototype = { let filePath = match[1].trim(); if (filePath.endsWith(".mjs")) { if (this.context) { this.context.report( comment, "import-globals-from does not support module files - use a direct import instead" ); } else { // Fall back to throwing an error, as we do not have a context in all situations, // e.g. when loading the environment. throw new Error( "import-globals-from does not support module files - use a direct import instead" ); } continue; } if (!path.isAbsolute(filePath)) { filePath = path.resolve(this.dirname, filePath); } else { Loading