Bug 1357546 - Fix how relative paths are handled in Windows for the ESLint import-browser-window-globals rule. r?Mossop
MozReview-Commit-ID: Q8YcLRSpkQ
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js
@@ -21,16 +21,21 @@ module.exports = function(context) {
// ---------------------------------------------------------------------------
// Public
// ---------------------------------------------------------------------------
return {
Program(node) {
let filePath = helpers.getAbsoluteFilePath(context);
let relativePath = path.relative(helpers.rootDir, filePath);
+ // We need to translate the path on Windows, due to the change
+ // from \ to /, and browserjsScripts assumes Posix.
+ if (path.win32) {
+ relativePath = relativePath.split(path.sep).join("/");
+ }
if (browserWindowEnv.browserjsScripts &&
browserWindowEnv.browserjsScripts.includes(relativePath)) {
for (let global in browserWindowEnv.globals) {
helpers.addVarToScope(global, context.getScope(),
browserWindowEnv.globals[global]);
}
}
--- a/tools/lint/eslint/eslint-plugin-mozilla/package.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -1,11 +1,11 @@
{
"name": "eslint-plugin-mozilla",
- "version": "0.2.40",
+ "version": "0.2.41",
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
"keywords": [
"eslint",
"eslintplugin",
"eslint-plugin",
"mozilla",
"firefox"
],